Class: ColonelKurtz::Block
- Inherits:
-
Object
- Object
- ColonelKurtz::Block
- Defined in:
- lib/colonel_kurtz/block.rb,
lib/colonel_kurtz/block/data.rb,
lib/colonel_kurtz/block/type.rb
Defined Under Namespace
Instance Attribute Summary collapse
-
#parent ⇒ Object
readonly
Returns the value of attribute parent.
Instance Method Summary collapse
- #children ⇒ Object
- #content ⇒ Object
-
#initialize(data) ⇒ Block
constructor
A new instance of Block.
- #type ⇒ Object
Constructor Details
#initialize(data) ⇒ Block
Returns a new instance of Block.
23 24 25 |
# File 'lib/colonel_kurtz/block.rb', line 23 def initialize(data) @data = Data.new(data).to_hash end |
Instance Attribute Details
#parent ⇒ Object (readonly)
Returns the value of attribute parent.
21 22 23 |
# File 'lib/colonel_kurtz/block.rb', line 21 def parent @parent end |
Instance Method Details
#children ⇒ Object
39 40 41 |
# File 'lib/colonel_kurtz/block.rb', line 39 def children @children ||= blocks.map{ |data| Block.new(data.merge("parent" => self)) } end |
#content ⇒ Object
31 32 33 |
# File 'lib/colonel_kurtz/block.rb', line 31 def content @content ||= data.fetch("content", {}) end |
#type ⇒ Object
27 28 29 |
# File 'lib/colonel_kurtz/block.rb', line 27 def type @type ||= Type.new(data.fetch("type")).to_sym end |