Class: SimpleSelector::Specificity
- Inherits:
-
Object
- Object
- SimpleSelector::Specificity
- Includes:
- Comparable
- Defined in:
- lib/simple_selector/specificity.rb
Instance Attribute Summary collapse
-
#a ⇒ Object
Returns the value of attribute a.
-
#b ⇒ Object
Returns the value of attribute b.
-
#c ⇒ Object
Returns the value of attribute c.
-
#d ⇒ Object
Returns the value of attribute d.
Instance Method Summary collapse
- #+(other) ⇒ Object
- #<=>(other) ⇒ Object
-
#initialize(a = 0, b = 0, c = 0, d = 0) ⇒ Specificity
constructor
A new instance of Specificity.
- #inspect ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(a = 0, b = 0, c = 0, d = 0) ⇒ Specificity
Returns a new instance of Specificity.
6 7 8 |
# File 'lib/simple_selector/specificity.rb', line 6 def initialize(a=0, b=0, c=0, d=0) @a, @b, @c, @d = a, b, c, d end |
Instance Attribute Details
#a ⇒ Object
Returns the value of attribute a.
10 11 12 |
# File 'lib/simple_selector/specificity.rb', line 10 def a @a end |
#b ⇒ Object
Returns the value of attribute b.
10 11 12 |
# File 'lib/simple_selector/specificity.rb', line 10 def b @b end |
#c ⇒ Object
Returns the value of attribute c.
10 11 12 |
# File 'lib/simple_selector/specificity.rb', line 10 def c @c end |
#d ⇒ Object
Returns the value of attribute d.
10 11 12 |
# File 'lib/simple_selector/specificity.rb', line 10 def d @d end |
Instance Method Details
#+(other) ⇒ Object
20 21 22 |
# File 'lib/simple_selector/specificity.rb', line 20 def +(other) self.class.new(a + other.a, b + other.b, c + other.c, d + other.d) end |
#<=>(other) ⇒ Object
12 13 14 15 16 17 18 |
# File 'lib/simple_selector/specificity.rb', line 12 def <=>(other) [:a, :b, :c, :d].each do |name| result = send(name) <=> other.send(name) return result unless result == 0 end 0 end |
#inspect ⇒ Object
28 29 30 |
# File 'lib/simple_selector/specificity.rb', line 28 def inspect "#<#{self.class} #{to_s.inspect}>" end |
#to_s ⇒ Object
24 25 26 |
# File 'lib/simple_selector/specificity.rb', line 24 def to_s "#{a},#{b},#{c},#{d}" end |