Class: RKit::Parser::Tree
Instance Attribute Summary collapse
-
#frame ⇒ Object
Returns the value of attribute frame.
-
#raw ⇒ Object
Returns the value of attribute raw.
-
#tag ⇒ Object
Returns the value of attribute tag.
Instance Method Summary collapse
- #branches ⇒ Object
-
#initialize(raw, tag: :document, frame:) ⇒ Tree
constructor
A new instance of Tree.
- #parsed ⇒ Object
Constructor Details
#initialize(raw, tag: :document, frame:) ⇒ Tree
Returns a new instance of Tree.
5 6 7 8 9 10 |
# File 'lib/r_kit/parser/tree.rb', line 5 def initialize raw, tag: :document, frame:; @raw = raw @tag = tag @frame = frame end |
Instance Attribute Details
#frame ⇒ Object
Returns the value of attribute frame.
3 4 5 |
# File 'lib/r_kit/parser/tree.rb', line 3 def frame @frame end |
#raw ⇒ Object
Returns the value of attribute raw.
3 4 5 |
# File 'lib/r_kit/parser/tree.rb', line 3 def raw @raw end |
#tag ⇒ Object
Returns the value of attribute tag.
3 4 5 |
# File 'lib/r_kit/parser/tree.rb', line 3 def tag @tag end |
Instance Method Details
#branches ⇒ Object
12 13 14 15 16 |
# File 'lib/r_kit/parser/tree.rb', line 12 def branches raw.split(/\n{2,}/).map do |raw_block| RKit::Parser::Leaf.new(raw_block, frame: frame) end end |
#parsed ⇒ Object
18 19 20 |
# File 'lib/r_kit/parser/tree.rb', line 18 def parsed branches.map(&:parsed).join("") end |