Class: ColonelKurtz::Block

Inherits:
Object
  • Object
show all
Defined in:
lib/colonel_kurtz/block.rb,
lib/colonel_kurtz/block/data.rb,
lib/colonel_kurtz/block/type.rb

Defined Under Namespace

Classes: Data, Type

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#parentObject (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

#childrenObject



39
40
41
# File 'lib/colonel_kurtz/block.rb', line 39

def children
  @children ||= blocks.map{ |data| Block.new(data.merge("parent" => self)) }
end

#contentObject



31
32
33
# File 'lib/colonel_kurtz/block.rb', line 31

def content
  @content ||= data.fetch("content", {})
end

#typeObject



27
28
29
# File 'lib/colonel_kurtz/block.rb', line 27

def type
  @type ||= Type.new(data.fetch("type")).to_sym
end