Class: CSSPool::Node

Inherits:
Object
  • Object
show all
Includes:
Enumerable
Defined in:
lib/csspool/node.rb

Instance Method Summary collapse

Instance Method Details

#==(other) ⇒ Object Also known as: eql?



22
23
24
25
26
# File 'lib/csspool/node.rb', line 22

def == other
  return false unless self.class == other.class

  accept Visitors::Comparable.new other
end

#accept(target) ⇒ Object



5
6
7
# File 'lib/csspool/node.rb', line 5

def accept target
  target.accept self
end

#childrenObject



33
34
35
# File 'lib/csspool/node.rb', line 33

def children
  accept Visitors::Children.new
end

#each(&block) ⇒ Object



29
30
31
# File 'lib/csspool/node.rb', line 29

def each &block
  Visitors::Iterator.new(block).accept self
end

#hashObject



37
38
39
# File 'lib/csspool/node.rb', line 37

def hash
  @hash ||= children.map { |child| child.hash }.hash
end

#to_css(options = {}) ⇒ Object Also known as: to_s



9
10
11
12
13
14
15
# File 'lib/csspool/node.rb', line 9

def to_css options={}
  if options[:minify]
    to_minified_css
  else
    accept Visitors::ToCSS.new
  end
end

#to_minified_cssObject



18
19
20
# File 'lib/csspool/node.rb', line 18

def to_minified_css
  accept Visitors::ToMinifiedCSS.new
end