Class: SyntaxTree::Haml::Root

Inherits:
Object
  • Object
show all
Defined in:
lib/syntax_tree/haml/root.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(node) ⇒ Root

Returns a new instance of Root.



8
9
10
# File 'lib/syntax_tree/haml/root.rb', line 8

def initialize(node)
  @node = node
end

Instance Attribute Details

#nodeObject (readonly)

Returns the value of attribute node.



6
7
8
# File 'lib/syntax_tree/haml/root.rb', line 6

def node
  @node
end

Instance Method Details

#format(q) ⇒ Object



12
13
14
15
16
17
# File 'lib/syntax_tree/haml/root.rb', line 12

def format(q)
  node.children.each do |child|
    child.format(q)
    q.breakable(force: true)
  end
end

#pretty_print(q) ⇒ Object



19
20
21
22
23
24
25
26
27
# File 'lib/syntax_tree/haml/root.rb', line 19

def pretty_print(q)
  q.group(2, "(root", ")") do
    if node.children.any?
      q.breakable
      q.text("children=")
      q.pp(node.children)
    end
  end
end