Class: SyntaxTree::Haml::SilentScript

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

Overview

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(node) ⇒ SilentScript

Returns a new instance of SilentScript.



9
10
11
# File 'lib/syntax_tree/haml/silent_script.rb', line 9

def initialize(node)
  @node = node
end

Instance Attribute Details

#nodeObject (readonly)

Returns the value of attribute node.



7
8
9
# File 'lib/syntax_tree/haml/silent_script.rb', line 7

def node
  @node
end

Instance Method Details

#format(q) ⇒ Object



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/syntax_tree/haml/silent_script.rb', line 13

def format(q)
  q.group do
    q.text("- ")
    q.text(node.value[:text].strip)

    node.children.each do |child|
      if continuation?(child)
        q.breakable(force: true)
        child.format(q)
      else
        q.indent do
          q.breakable(force: true)
          child.format(q)
        end
      end
    end
  end
end

#pretty_print(q) ⇒ Object



32
33
34
35
36
37
38
39
40
41
42
43
44
# File 'lib/syntax_tree/haml/silent_script.rb', line 32

def pretty_print(q)
  q.group(2, "(silent_script", ")") do
    q.breakable
    q.text("text=")
    q.pp(node.value[:text])

    if node.children.any?
      q.breakable
      q.text("children=")
      q.pp(node.children)
    end
  end
end