Class: Smartdown::Model::Node
- Inherits:
-
Struct
- Object
- Struct
- Smartdown::Model::Node
- Defined in:
- lib/smartdown/model/node.rb
Instance Attribute Summary collapse
-
#elements ⇒ Object
Returns the value of attribute elements.
-
#front_matter ⇒ Object
Returns the value of attribute front_matter.
-
#name ⇒ Object
Returns the value of attribute name.
Instance Method Summary collapse
- #body ⇒ Object
-
#initialize(name, elements, front_matter = nil) ⇒ Node
constructor
A new instance of Node.
- #questions ⇒ Object
- #title ⇒ Object
Constructor Details
#initialize(name, elements, front_matter = nil) ⇒ Node
Returns a new instance of Node.
6 7 8 |
# File 'lib/smartdown/model/node.rb', line 6 def initialize(name, elements, front_matter = nil) super(name, elements, front_matter || Smartdown::Model::FrontMatter.new) end |
Instance Attribute Details
#elements ⇒ Object
Returns the value of attribute elements
5 6 7 |
# File 'lib/smartdown/model/node.rb', line 5 def elements @elements end |
#front_matter ⇒ Object
Returns the value of attribute front_matter
5 6 7 |
# File 'lib/smartdown/model/node.rb', line 5 def front_matter @front_matter end |
#name ⇒ Object
Returns the value of attribute name
5 6 7 |
# File 'lib/smartdown/model/node.rb', line 5 def name @name end |
Instance Method Details
#body ⇒ Object
20 21 22 |
# File 'lib/smartdown/model/node.rb', line 20 def body markdown_blocks[1..-1].map { |block| as_markdown(block) }.compact.join("\n") end |
#questions ⇒ Object
10 11 12 13 14 |
# File 'lib/smartdown/model/node.rb', line 10 def questions elements.select do |element| element.class.to_s.include?("Smartdown::Model::Element::Question") end end |
#title ⇒ Object
16 17 18 |
# File 'lib/smartdown/model/node.rb', line 16 def title h1s.first ? h1s.first.content : "" end |