Class: CssParserMaster::Selector
- Inherits:
-
Object
- Object
- CssParserMaster::Selector
- Includes:
- DeclarationAPI
- Defined in:
- lib/css_parser_master/selector.rb
Instance Attribute Summary collapse
-
#declarations ⇒ Object
Returns the value of attribute declarations.
-
#selector ⇒ Object
Returns the value of attribute selector.
-
#specificity ⇒ Object
Returns the value of attribute specificity.
Instance Method Summary collapse
- #declarations_to_s(options = {}) ⇒ Object
-
#initialize(selector, declarations, specificity) ⇒ Selector
constructor
A new instance of Selector.
- #to_text ⇒ Object
Methods included from DeclarationAPI
#add_declaration!, #each_declaration, #ensure_valid_declarations!, #parse_declarations!
Constructor Details
#initialize(selector, declarations, specificity) ⇒ Selector
Returns a new instance of Selector.
9 10 11 12 13 14 15 16 |
# File 'lib/css_parser_master/selector.rb', line 9 def initialize(selector, declarations, specificity) @selector = selector @order = 0 @declarations = {} parse_declarations!(declarations) # puts "init @declarations: #{@declarations}" @specificity = specificity end |
Instance Attribute Details
#declarations ⇒ Object
Returns the value of attribute declarations.
7 8 9 |
# File 'lib/css_parser_master/selector.rb', line 7 def declarations @declarations end |
#selector ⇒ Object
Returns the value of attribute selector.
7 8 9 |
# File 'lib/css_parser_master/selector.rb', line 7 def selector @selector end |
#specificity ⇒ Object
Returns the value of attribute specificity.
7 8 9 |
# File 'lib/css_parser_master/selector.rb', line 7 def specificity @specificity end |
Instance Method Details
#declarations_to_s(options = {}) ⇒ Object
18 19 20 21 22 23 24 25 |
# File 'lib/css_parser_master/selector.rb', line 18 def declarations_to_s( = {}) # puts "declarations_to_s: #{declarations.inspect}" s = declarations.map do |decl| decl[1].to_text end.join('') # puts "res: #{s}" s end |
#to_text ⇒ Object
28 29 30 |
# File 'lib/css_parser_master/selector.rb', line 28 def to_text "#{selector}\n{\n#{declarations_to_s}\n} \n" end |