Class: Csscss::Declaration
- Inherits:
-
Struct
- Object
- Struct
- Csscss::Declaration
- Defined in:
- lib/csscss/types.rb
Instance Attribute Summary collapse
-
#parents ⇒ Object
Returns the value of attribute parents.
-
#property ⇒ Object
Returns the value of attribute property.
-
#value ⇒ Object
Returns the value of attribute value.
Class Method Summary collapse
Instance Method Summary collapse
- #<(other) ⇒ Object
- #<=>(other) ⇒ Object
- #==(other) ⇒ Object
- #>(other) ⇒ Object
- #derivative? ⇒ Boolean
- #eql?(other) ⇒ Boolean
- #hash ⇒ Object
- #inspect ⇒ Object
- #to_s ⇒ Object
- #without_parents ⇒ Object
Instance Attribute Details
#parents ⇒ Object
Returns the value of attribute parents
2 3 4 |
# File 'lib/csscss/types.rb', line 2 def parents @parents end |
#property ⇒ Object
Returns the value of attribute property
2 3 4 |
# File 'lib/csscss/types.rb', line 2 def property @property end |
#value ⇒ Object
Returns the value of attribute value
2 3 4 |
# File 'lib/csscss/types.rb', line 2 def value @value end |
Class Method Details
.from_csspool(dec) ⇒ Object
3 4 5 |
# File 'lib/csscss/types.rb', line 3 def self.from_csspool(dec) new(dec.property.to_s.downcase, dec.expressions.join(" ").downcase) end |
.from_parser(property, value, clean = true) ⇒ Object
7 8 9 10 11 12 13 14 15 |
# File 'lib/csscss/types.rb', line 7 def self.from_parser(property, value, clean = true) value = value.to_s property = property.to_s if clean value = value.downcase property = property.downcase end new(property, value.strip) end |
Instance Method Details
#<(other) ⇒ Object
56 57 58 |
# File 'lib/csscss/types.rb', line 56 def <(other) other > self end |
#<=>(other) ⇒ Object
48 49 50 |
# File 'lib/csscss/types.rb', line 48 def <=>(other) property <=> other.property end |
#==(other) ⇒ Object
31 32 33 34 35 36 37 38 |
# File 'lib/csscss/types.rb', line 31 def ==(other) if other.respond_to?(:property) && other.respond_to?(:value) # using eql? tanks performance property == other.property && normalize_value(value) == normalize_value(other.value) else false end end |
#>(other) ⇒ Object
52 53 54 |
# File 'lib/csscss/types.rb', line 52 def >(other) other.derivative? && other.parents.include?(self) end |
#derivative? ⇒ Boolean
17 18 19 |
# File 'lib/csscss/types.rb', line 17 def derivative? !parents.nil? end |
#eql?(other) ⇒ Boolean
44 45 46 |
# File 'lib/csscss/types.rb', line 44 def eql?(other) hash == other.hash end |
#hash ⇒ Object
40 41 42 |
# File 'lib/csscss/types.rb', line 40 def hash [property, normalize_value(value)].hash end |
#inspect ⇒ Object
64 65 66 67 68 69 70 |
# File 'lib/csscss/types.rb', line 64 def inspect if parents "<#{self.class} #{to_s} (parents: #{parents})>" else "<#{self.class} #{to_s}>" end end |
#to_s ⇒ Object
60 61 62 |
# File 'lib/csscss/types.rb', line 60 def to_s "#{property}: #{value}" end |
#without_parents ⇒ Object
21 22 23 24 25 26 27 28 29 |
# File 'lib/csscss/types.rb', line 21 def without_parents if derivative? dup.tap do |duped| duped.parents = nil end else self end end |