Class: Sass::Selector::Id

Inherits:
Simple
  • Object
show all
Defined in:
/home/nweiz/code/sass-site/.sass/lib/sass/selector.rb

Overview

An id selector (e.g. #foo).

Instance Attribute Summary (collapse)

Attributes inherited from Simple

#filename, #line

Instance Method Summary (collapse)

Methods inherited from Simple

#eql?, #equality_key, #hash, #inspect, #unify_namespaces

Constructor Details

- (Id) initialize(name)

Returns a new instance of Id

Parameters:

  • name (String)

    The id name



86
87
88
# File '/home/nweiz/code/sass-site/.sass/lib/sass/selector.rb', line 86

def initialize(name)
  @name = name
end

Instance Attribute Details

- (String) name (readonly)

The id name.

Returns:

  • (String)


83
84
85
# File '/home/nweiz/code/sass-site/.sass/lib/sass/selector.rb', line 83

def name
  @name
end

Instance Method Details

- specificity



109
110
111
# File '/home/nweiz/code/sass-site/.sass/lib/sass/selector.rb', line 109

def specificity
  SPECIFICITY_BASE**2
end

- to_s(opts = {})

See Also:

  • Selector#to_s


95
96
97
# File '/home/nweiz/code/sass-site/.sass/lib/sass/selector.rb', line 95

def to_s(opts = {})
  "#" + @name
end

- unify(sels)

Returns nil if sels contains an Sass::Selector::Id selector with a different name than this one.

See Also:

  • Selector#unify


103
104
105
106
# File '/home/nweiz/code/sass-site/.sass/lib/sass/selector.rb', line 103

def unify(sels)
  return if sels.any? {|sel2| sel2.is_a?(Id) && name != sel2.name}
  super
end

- (Boolean) unique?

Returns:

  • (Boolean)


90
91
92
# File '/home/nweiz/code/sass-site/.sass/lib/sass/selector.rb', line 90

def unique?
  true
end