Class: CommandMapper::Gen::Types::KeyValue

Inherits:
Object
  • Object
show all
Defined in:
lib/command_mapper/gen/types/key_value.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(separator: '=') ⇒ KeyValue

Initializes the key-value type.

Parameters:

  • separator (String) (defaults to: '=')

    The separator character.



15
16
17
# File 'lib/command_mapper/gen/types/key_value.rb', line 15

def initialize(separator: '=')
  @separator = separator
end

Instance Attribute Details

#separatorString (readonly)

Returns:

  • (String)


7
8
9
# File 'lib/command_mapper/gen/types/key_value.rb', line 7

def separator
  @separator
end

Instance Method Details

#to_rubyString

Converts the key-value type to Ruby source code.

Returns:

  • (String)


24
25
26
27
28
29
# File 'lib/command_mapper/gen/types/key_value.rb', line 24

def to_ruby
  ruby = "KeyValue.new("
  ruby << "separator: #{@separator.inspect}" unless @separator == '='
  ruby << ")"
  ruby
end