Class: RgGen::RegisterMap::RegisterBlockFactory
- Inherits:
-
ComponentFactory
- Object
- Base::ComponentFactory
- InputBase::ComponentFactory
- ComponentFactory
- RgGen::RegisterMap::RegisterBlockFactory
- Defined in:
- lib/rggen/core_components/register_map/register_block_factory.rb
Instance Attribute Summary
Attributes inherited from InputBase::ComponentFactory
Attributes inherited from Base::ComponentFactory
#child_factory, #item_factories, #target_component
Instance Method Summary collapse
- #cell_blocks(sheet) ⇒ Object
- #create_active_items(register_block, sheet) ⇒ Object
- #create_children(register_block, configuration, sheet) ⇒ Object
Methods inherited from ComponentFactory
Methods inherited from InputBase::ComponentFactory
Methods inherited from Base::ComponentFactory
#create, #initialize, #root_factory
Constructor Details
This class inherits a constructor from RgGen::Base::ComponentFactory
Instance Method Details
#cell_blocks(sheet) ⇒ Object
17 18 19 20 21 22 23 24 25 26 |
# File 'lib/rggen/core_components/register_map/register_block_factory.rb', line 17 def cell_blocks(sheet) drop_row_size = active_item_factories.size + 2 drop_column_size = 1 sheet.rows.drop(drop_row_size).each_with_object([]) do |row, blocks| valid_cells = row.drop(drop_column_size) next if valid_cells.all?(&:empty?) blocks << [] unless valid_cells.first.empty? blocks.last << valid_cells end end |
#create_active_items(register_block, sheet) ⇒ Object
4 5 6 7 8 9 |
# File 'lib/rggen/core_components/register_map/register_block_factory.rb', line 4 def create_active_items(register_block, sheet) active_item_factories.each_value.with_index do |factory, index| cell = sheet[index, 2] create_item(factory, register_block, cell) end end |
#create_children(register_block, configuration, sheet) ⇒ Object
11 12 13 14 15 |
# File 'lib/rggen/core_components/register_map/register_block_factory.rb', line 11 def create_children(register_block, configuration, sheet) cell_blocks(sheet).each do |block| create_child(register_block, configuration, block) end end |