Class: CommandMapper::Gen::Types::Map
- Inherits:
-
Object
- Object
- CommandMapper::Gen::Types::Map
- Defined in:
- lib/command_mapper/gen/types/map.rb
Instance Attribute Summary collapse
- #map ⇒ Hash{Object => String} readonly
Instance Method Summary collapse
-
#initialize(map) ⇒ Map
constructor
Initializes the map type.
-
#to_ruby ⇒ String
Converts the map type to Ruby source code.
Constructor Details
#initialize(map) ⇒ Map
Initializes the map type.
14 15 16 |
# File 'lib/command_mapper/gen/types/map.rb', line 14 def initialize(map) @map = map end |
Instance Attribute Details
#map ⇒ Hash{Object => String} (readonly)
7 8 9 |
# File 'lib/command_mapper/gen/types/map.rb', line 7 def map @map end |
Instance Method Details
#to_ruby ⇒ String
Converts the map type to Ruby source code.
23 24 25 26 27 28 29 30 31 |
# File 'lib/command_mapper/gen/types/map.rb', line 23 def to_ruby pairs = [] @map.each do |value,string| pairs << "#{value.inspect} => #{string.inspect}" end return "Map.new(#{pairs.join(', ')})" end |