Class: RgGen::RegisterMap::GenericMap

Inherits:
Object
  • Object
show all
Defined in:
lib/rggen/core_components/register_map/generic_map.rb

Defined Under Namespace

Classes: Cell, Sheet

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(file) ⇒ GenericMap

Returns a new instance of GenericMap.



50
51
52
53
# File 'lib/rggen/core_components/register_map/generic_map.rb', line 50

def initialize(file)
  @file   = file
  @sheets = {}
end

Instance Attribute Details

#fileObject (readonly)

Returns the value of attribute file.



55
56
57
# File 'lib/rggen/core_components/register_map/generic_map.rb', line 55

def file
  @file
end

Instance Method Details

#[](sheet_name_or_index) ⇒ Object



57
58
59
60
61
62
63
64
# File 'lib/rggen/core_components/register_map/generic_map.rb', line 57

def [](sheet_name_or_index)
  case sheet_name_or_index
  when String
    @sheets[sheet_name_or_index]  ||= Sheet.new(file, sheet_name_or_index)
  when Integer
    sheets[sheet_name_or_index]
  end
end

#[]=(sheet_name, table) ⇒ Object



66
67
68
69
70
71
72
73
# File 'lib/rggen/core_components/register_map/generic_map.rb', line 66

def []=(sheet_name, table)
  @sheets[sheet_name] = Sheet.new(file, sheet_name)
  table.each_with_index do |values, row|
    values.each_with_index do |value, column|
      @sheets[sheet_name][row, column]  = value
    end
  end
end

#sheetsObject



75
76
77
# File 'lib/rggen/core_components/register_map/generic_map.rb', line 75

def sheets
  @sheets.values
end