Class: Sass::Selector::Id

Inherits:
Simple
  • Object
show all
Defined in:
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?, #hash, #inspect, #to_s, #unify_namespaces

Constructor Details

#initialize(name) ⇒ Id

Returns a new instance of Id.

Parameters:



77
78
79
# File 'lib/sass/selector.rb', line 77

def initialize(name)
  @name = name
end

Instance Attribute Details

#nameArray<String, Sass::Script::Node> (readonly)

The id name.

Returns:



74
75
76
# File 'lib/sass/selector.rb', line 74

def name
  @name
end

Instance Method Details

#specificity



96
97
98
# File 'lib/sass/selector.rb', line 96

def specificity
  SPECIFICITY_BASE**2
end

#to_a

See Also:

  • Selector#to_a


82
83
84
# File 'lib/sass/selector.rb', line 82

def to_a
  ["#", *@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


90
91
92
93
# File 'lib/sass/selector.rb', line 90

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