Class: CSSPool::Node
Direct Known Subclasses
CSS::Charset, CSS::Declaration, CSS::Document, CSS::DocumentQuery, CSS::FontfaceRule, CSS::ImportRule, CSS::KeyframesBlock, CSS::KeyframesRule, CSS::MediaFeature, CSS::MediaQuery, CSS::MediaQueryList, CSS::MediaType, CSS::NamespaceRule, CSS::RuleSet, CSS::SupportsRule, Selector, Selectors::Additional, Selectors::Simple, Terms::Function, Terms::Ident, Terms::Math, Terms::Resolution, Terms::Rgb
Instance Attribute Summary collapse
-
#inner_end_pos ⇒ Object
These give the position of this node in the source CSS.
-
#inner_start_pos ⇒ Object
These give the position of this node in the source CSS.
-
#outer_end_pos ⇒ Object
These give the position of this node in the source CSS.
-
#outer_start_pos ⇒ Object
These give the position of this node in the source CSS.
Instance Method Summary collapse
- #==(other) ⇒ Object (also: #eql?)
- #accept(target) ⇒ Object
- #children ⇒ Object
- #each(&block) ⇒ Object
- #hash ⇒ Object
- #to_css(options = {}) ⇒ Object (also: #to_s)
- #to_minified_css ⇒ Object
Instance Attribute Details
#inner_end_pos ⇒ Object
These give the position of this node in the source CSS. Not all node types are supported. “Outer” represents the start/end of this node, “inner” represents the start/end of this node’s children. Outer will not contain leading or trailing comments or whitespace, while inner will. For example, in this code:
1 /* test1 */ 2 @document domain(‘example.com’) { 3 /* test2 */ 4 * { color: blue; } 5 /* test3 */ 6 } /* test4 */
The index will represent the position: outer_start_pos: 2:0 inner_start_pos: 2:33 inner_end_pos: 6:0 outer_end_pos: 6:1
25 26 27 |
# File 'lib/csspool/node.rb', line 25 def inner_end_pos @inner_end_pos end |
#inner_start_pos ⇒ Object
These give the position of this node in the source CSS. Not all node types are supported. “Outer” represents the start/end of this node, “inner” represents the start/end of this node’s children. Outer will not contain leading or trailing comments or whitespace, while inner will. For example, in this code:
1 /* test1 */ 2 @document domain(‘example.com’) { 3 /* test2 */ 4 * { color: blue; } 5 /* test3 */ 6 } /* test4 */
The index will represent the position: outer_start_pos: 2:0 inner_start_pos: 2:33 inner_end_pos: 6:0 outer_end_pos: 6:1
25 26 27 |
# File 'lib/csspool/node.rb', line 25 def inner_start_pos @inner_start_pos end |
#outer_end_pos ⇒ Object
These give the position of this node in the source CSS. Not all node types are supported. “Outer” represents the start/end of this node, “inner” represents the start/end of this node’s children. Outer will not contain leading or trailing comments or whitespace, while inner will. For example, in this code:
1 /* test1 */ 2 @document domain(‘example.com’) { 3 /* test2 */ 4 * { color: blue; } 5 /* test3 */ 6 } /* test4 */
The index will represent the position: outer_start_pos: 2:0 inner_start_pos: 2:33 inner_end_pos: 6:0 outer_end_pos: 6:1
25 26 27 |
# File 'lib/csspool/node.rb', line 25 def outer_end_pos @outer_end_pos end |
#outer_start_pos ⇒ Object
These give the position of this node in the source CSS. Not all node types are supported. “Outer” represents the start/end of this node, “inner” represents the start/end of this node’s children. Outer will not contain leading or trailing comments or whitespace, while inner will. For example, in this code:
1 /* test1 */ 2 @document domain(‘example.com’) { 3 /* test2 */ 4 * { color: blue; } 5 /* test3 */ 6 } /* test4 */
The index will represent the position: outer_start_pos: 2:0 inner_start_pos: 2:33 inner_end_pos: 6:0 outer_end_pos: 6:1
25 26 27 |
# File 'lib/csspool/node.rb', line 25 def outer_start_pos @outer_start_pos end |
Instance Method Details
#==(other) ⇒ Object Also known as: eql?
44 45 46 47 48 |
# File 'lib/csspool/node.rb', line 44 def == other return false unless self.class == other.class accept Visitors::Comparable.new other end |
#accept(target) ⇒ Object
27 28 29 |
# File 'lib/csspool/node.rb', line 27 def accept target target.accept self end |
#children ⇒ Object
55 56 57 |
# File 'lib/csspool/node.rb', line 55 def children accept Visitors::Children.new end |
#each(&block) ⇒ Object
51 52 53 |
# File 'lib/csspool/node.rb', line 51 def each &block Visitors::Iterator.new(block).accept self end |
#hash ⇒ Object
59 60 61 |
# File 'lib/csspool/node.rb', line 59 def hash @hash ||= children.map { |child| child.hash }.hash end |
#to_css(options = {}) ⇒ Object Also known as: to_s
31 32 33 34 35 36 37 |
# File 'lib/csspool/node.rb', line 31 def to_css ={} if [:minify] to_minified_css else accept Visitors::ToCSS.new end end |
#to_minified_css ⇒ Object
40 41 42 |
# File 'lib/csspool/node.rb', line 40 def to_minified_css accept Visitors::ToMinifiedCSS.new end |