Class: Block

Inherits:
Object
  • Object
show all
Defined in:
lib/block.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(id, items) ⇒ Block

Returns a new instance of Block.



4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
# File 'lib/block.rb', line 4

def initialize(id, items)
  item = items[id]
  @id = id
  @content = item['content']
  @category = item['category']
  @attribute_container = item['attributeContainer']
  @attribute = item['attribute']
  @type = item['type']
  @association = item['association']
  @sub_blocks = []
  item['subItemIds'].each do |sub_item_id|
    sub_item_id = sub_item_id.to_s
    @sub_blocks << Block.new(sub_item_id, items)
  end
end

Instance Attribute Details

#associationObject

Returns the value of attribute association.



2
3
4
# File 'lib/block.rb', line 2

def association
  @association
end

#attributeObject

Returns the value of attribute attribute.



2
3
4
# File 'lib/block.rb', line 2

def attribute
  @attribute
end

#attribute_containerObject

Returns the value of attribute attribute_container.



2
3
4
# File 'lib/block.rb', line 2

def attribute_container
  @attribute_container
end

#categoryObject

Returns the value of attribute category.



2
3
4
# File 'lib/block.rb', line 2

def category
  @category
end

#contentObject

Returns the value of attribute content.



2
3
4
# File 'lib/block.rb', line 2

def content
  @content
end

#idObject

Returns the value of attribute id.



2
3
4
# File 'lib/block.rb', line 2

def id
  @id
end

#sub_blocksObject

Returns the value of attribute sub_blocks.



2
3
4
# File 'lib/block.rb', line 2

def sub_blocks
  @sub_blocks
end

#typeObject

Returns the value of attribute type.



2
3
4
# File 'lib/block.rb', line 2

def type
  @type
end

Class Method Details

.allObject



20
21
22
# File 'lib/block.rb', line 20

def self.all
  ObjectSpace.each_object(self).to_a
end

.find(id) ⇒ Object



24
25
26
# File 'lib/block.rb', line 24

def self.find(id)
  all.each { |block| return block if block.id == id }
end