Class: RKit::Parser::Leaf
Instance Attribute Summary collapse
-
#attributes ⇒ Object
Returns the value of attribute attributes.
-
#content ⇒ Object
Returns the value of attribute content.
-
#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
-
#initialize(raw, frame:) ⇒ Leaf
constructor
A new instance of Leaf.
- #parsed ⇒ Object
- #parsed_content ⇒ Object
Constructor Details
#initialize(raw, frame:) ⇒ Leaf
Returns a new instance of Leaf.
5 6 7 8 9 10 |
# File 'lib/r_kit/parser/leaf.rb', line 5 def initialize raw, frame:; @raw = raw @frame = frame @tag, @attributes, @content = parse_blocks @attributes ||= {} end |
Instance Attribute Details
#attributes ⇒ Object
Returns the value of attribute attributes.
3 4 5 |
# File 'lib/r_kit/parser/leaf.rb', line 3 def attributes @attributes end |
#content ⇒ Object
Returns the value of attribute content.
3 4 5 |
# File 'lib/r_kit/parser/leaf.rb', line 3 def content @content end |
#frame ⇒ Object
Returns the value of attribute frame.
3 4 5 |
# File 'lib/r_kit/parser/leaf.rb', line 3 def frame @frame end |
#raw ⇒ Object
Returns the value of attribute raw.
3 4 5 |
# File 'lib/r_kit/parser/leaf.rb', line 3 def raw @raw end |
#tag ⇒ Object
Returns the value of attribute tag.
3 4 5 |
# File 'lib/r_kit/parser/leaf.rb', line 3 def tag @tag end |
Instance Method Details
#parsed ⇒ Object
12 13 14 15 16 17 18 19 20 |
# File 'lib/r_kit/parser/leaf.rb', line 12 def parsed if content && tag "<#{ tag } #{ attributes.map{|k,v| "#{k}='#{v}'"}.join }>#{ parsed_content }</#{ tag }>" elsif tag "<#{ tag } #{ attributes.map{|k,v| "#{k}='#{v}'"}.join }/>" elsif content content end end |
#parsed_content ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/r_kit/parser/leaf.rb', line 22 def parsed_content Array(content) .map{ |c| case c when String parse_inlines when RKit::Parser::Leaf c.parsed end } .join("") end |