Class: MiniCSS::AST::Rule
- Inherits:
-
Object
- Object
- MiniCSS::AST::Rule
- Defined in:
- lib/minicss/ast/rule.rb
Instance Attribute Summary collapse
-
#child_rules ⇒ Object
Returns the value of attribute child_rules.
-
#decls ⇒ Object
Returns the value of attribute decls.
-
#raw_selector ⇒ Object
Returns the value of attribute raw_selector.
-
#selector ⇒ Object
Returns the value of attribute selector.
Instance Method Summary collapse
-
#initialize(struct) ⇒ Rule
constructor
A new instance of Rule.
- #valid_selector? ⇒ Boolean
Constructor Details
#initialize(struct) ⇒ Rule
Returns a new instance of Rule.
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/minicss/ast/rule.rb', line 8 def initialize(struct) raise "Expected CSS::AST::QualifiedRule, found #{struct.class}" unless struct.is_a? CSS::AST::QualifiedRule @raw_selector = struct.prelude.map(&:literal).join begin @selector = Sel.parse(raw_selector) @valid_selector = true rescue StandardError => e pos = struct.prelude.first.pos_start @selector = "Failed parsing selector at #{pos.line}:#{pos.column}: #{e}" @valid_selector = false end @child_rules = struct.child_rules.map { AST.convert(it) } @decls = struct.decls.map { AST.convert(it) } end |
Instance Attribute Details
#child_rules ⇒ Object
Returns the value of attribute child_rules.
6 7 8 |
# File 'lib/minicss/ast/rule.rb', line 6 def child_rules @child_rules end |
#decls ⇒ Object
Returns the value of attribute decls.
6 7 8 |
# File 'lib/minicss/ast/rule.rb', line 6 def decls @decls end |
#raw_selector ⇒ Object
Returns the value of attribute raw_selector.
6 7 8 |
# File 'lib/minicss/ast/rule.rb', line 6 def raw_selector @raw_selector end |
#selector ⇒ Object
Returns the value of attribute selector.
6 7 8 |
# File 'lib/minicss/ast/rule.rb', line 6 def selector @selector end |
Instance Method Details
#valid_selector? ⇒ Boolean
25 |
# File 'lib/minicss/ast/rule.rb', line 25 def valid_selector? = @valid_selector |