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.



39
40
41
42
# File 'lib/rggen/core_components/register_map/generic_map.rb', line 39

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

Instance Attribute Details

#fileObject (readonly)

Returns the value of attribute file.



44
45
46
# File 'lib/rggen/core_components/register_map/generic_map.rb', line 44

def file
  @file
end

Instance Method Details

#[](sheet_name_or_index) ⇒ Object



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

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



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

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



64
65
66
# File 'lib/rggen/core_components/register_map/generic_map.rb', line 64

def sheets
  @sheets.values
end