Class: CssParserMaster::Declaration

Inherits:
Object
  • Object
show all
Defined in:
lib/css_parser_master/declaration.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(property, value, important = false, order = 0) ⇒ Declaration

Returns a new instance of Declaration.



5
6
7
8
9
10
11
# File 'lib/css_parser_master/declaration.rb', line 5

def initialize(property, value, important = false, order = 0)
  # puts "init new declaration: #{property}"
  @property = property
  @value = value
  @important = important
  @order = order            
end

Instance Attribute Details

#importantObject

Returns the value of attribute important.



3
4
5
# File 'lib/css_parser_master/declaration.rb', line 3

def important
  @important
end

#orderObject

Returns the value of attribute order.



3
4
5
# File 'lib/css_parser_master/declaration.rb', line 3

def order
  @order
end

#propertyObject

Returns the value of attribute property.



3
4
5
# File 'lib/css_parser_master/declaration.rb', line 3

def property
  @property
end

#valueObject

Returns the value of attribute value.



3
4
5
# File 'lib/css_parser_master/declaration.rb', line 3

def value
  @value
end

Instance Method Details

#[](index) ⇒ Object



13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/css_parser_master/declaration.rb', line 13

def [] index
  case index
  when :value
    value
  when :order
    order
  when :is_important
    important
  when :property
    property
  end
end

#to_text(importance = nil) ⇒ Object



26
27
28
# File 'lib/css_parser_master/declaration.rb', line 26

def to_text(importance = nil)
  "#{property}: #{value}#{ ' !important' if important || importance};"
end