Class: RgGen::RegisterMap::GenericMap
- Inherits:
-
Object
- Object
- RgGen::RegisterMap::GenericMap
- Defined in:
- lib/rggen/core_components/register_map/generic_map.rb
Defined Under Namespace
Instance Attribute Summary collapse
-
#file ⇒ Object
readonly
Returns the value of attribute file.
Instance Method Summary collapse
- #[](sheet_name_or_index) ⇒ Object
- #[]=(sheet_name, table) ⇒ Object
-
#initialize(file) ⇒ GenericMap
constructor
A new instance of GenericMap.
- #sheets ⇒ Object
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
#file ⇒ Object (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 |
#sheets ⇒ Object
64 65 66 |
# File 'lib/rggen/core_components/register_map/generic_map.rb', line 64 def sheets @sheets.values end |