Class: CSSPool::CSS::Document
Instance Attribute Summary collapse
-
#charsets ⇒ Object
Returns the value of attribute charsets.
-
#import_rules ⇒ Object
Returns the value of attribute import_rules.
-
#parent ⇒ Object
Returns the value of attribute parent.
-
#parent_import_rule ⇒ Object
Returns the value of attribute parent_import_rule.
-
#rule_sets ⇒ Object
Returns the value of attribute rule_sets.
Class Method Summary collapse
Instance Method Summary collapse
- #[](selector) ⇒ Object
-
#initialize ⇒ Document
constructor
A new instance of Document.
Methods included from Visitable
#==, #accept, #children, #each, #hash, #to_css
Constructor Details
#initialize ⇒ Document
Returns a new instance of Document.
20 21 22 23 24 25 26 |
# File 'lib/csspool/css/document.rb', line 20 def initialize @rule_sets = [] @charsets = [] @import_rules = [] @parent = nil @parent_import_rule = nil end |
Instance Attribute Details
#charsets ⇒ Object
Returns the value of attribute charsets.
15 16 17 |
# File 'lib/csspool/css/document.rb', line 15 def charsets @charsets end |
#import_rules ⇒ Object
Returns the value of attribute import_rules.
16 17 18 |
# File 'lib/csspool/css/document.rb', line 16 def import_rules @import_rules end |
#parent ⇒ Object
Returns the value of attribute parent.
17 18 19 |
# File 'lib/csspool/css/document.rb', line 17 def parent @parent end |
#parent_import_rule ⇒ Object
Returns the value of attribute parent_import_rule.
18 19 20 |
# File 'lib/csspool/css/document.rb', line 18 def parent_import_rule @parent_import_rule end |
#rule_sets ⇒ Object
Returns the value of attribute rule_sets.
14 15 16 |
# File 'lib/csspool/css/document.rb', line 14 def rule_sets @rule_sets end |
Class Method Details
.parse(string) ⇒ Object
4 5 6 7 8 9 10 11 12 |
# File 'lib/csspool/css/document.rb', line 4 def self.parse string unless string && string.length > 0 return CSSPool::CSS::Document.new end handler = CSSPool::CSS::DocumentHandler.new parser = CSSPool::SAC::Parser.new(handler) parser.parse(string) handler.document end |
Instance Method Details
#[](selector) ⇒ Object
28 29 30 31 |
# File 'lib/csspool/css/document.rb', line 28 def [] selector selectors = CSSPool.CSS("#{selector} {}").rule_sets.first.selectors rule_sets.find_all { |rs| rs.selectors == selectors} end |