Class: Burner::Modeling::KeyMapping

Inherits:
Object
  • Object
show all
Defined in:
lib/burner/modeling/key_mapping.rb

Overview

Generic mapping from a key to another key. The argument ‘to’ is optional and if it is blank then the ‘from’ value will be used for the ‘to’ as well.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(from:, to: '') ⇒ KeyMapping

Returns a new instance of KeyMapping.

Raises:

  • (ArgumentError)


19
20
21
22
23
24
25
26
# File 'lib/burner/modeling/key_mapping.rb', line 19

def initialize(from:, to: '')
  raise ArgumentError, 'from is required' if from.to_s.empty?

  @from = from.to_s
  @to   = to.to_s.empty? ? @from : to.to_s

  freeze
end

Instance Attribute Details

#fromObject (readonly)

Returns the value of attribute from.



17
18
19
# File 'lib/burner/modeling/key_mapping.rb', line 17

def from
  @from
end

#toObject (readonly)

Returns the value of attribute to.



17
18
19
# File 'lib/burner/modeling/key_mapping.rb', line 17

def to
  @to
end