Class: SyntaxTree::Haml::Filter
- Inherits:
-
Object
- Object
- SyntaxTree::Haml::Filter
- Defined in:
- lib/syntax_tree/haml/filter.rb
Overview
Instance Attribute Summary collapse
-
#node ⇒ Object
readonly
Returns the value of attribute node.
Instance Method Summary collapse
- #format(q) ⇒ Object
-
#initialize(node) ⇒ Filter
constructor
A new instance of Filter.
- #pretty_print(q) ⇒ Object
Constructor Details
#initialize(node) ⇒ Filter
Returns a new instance of Filter.
9 10 11 |
# File 'lib/syntax_tree/haml/filter.rb', line 9 def initialize(node) @node = node end |
Instance Attribute Details
#node ⇒ Object (readonly)
Returns the value of attribute node.
7 8 9 |
# File 'lib/syntax_tree/haml/filter.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 |
# File 'lib/syntax_tree/haml/filter.rb', line 13 def format(q) q.group do q.text(":") q.text(node.value[:name]) q.indent do q.breakable(force: true) segments = node.value[:text].strip.split("\n") q.seplist(segments, -> { q.breakable(force: true) }) do |segment| q.text(segment) end end end end |
#pretty_print(q) ⇒ Object
29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/syntax_tree/haml/filter.rb', line 29 def pretty_print(q) q.group(2, "(filter", ")") do q.breakable q.text("name=") q.text(node.value[:name]) q.breakable q.text("text=") q.pp(node.value[:text]) end end |