Class: Burner::Modeling::KeyMapping
- Inherits:
-
Object
- Object
- Burner::Modeling::KeyMapping
- 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
-
#from ⇒ Object
readonly
Returns the value of attribute from.
-
#to ⇒ Object
readonly
Returns the value of attribute to.
Instance Method Summary collapse
-
#initialize(from:, to: '') ⇒ KeyMapping
constructor
A new instance of KeyMapping.
Constructor Details
#initialize(from:, to: '') ⇒ KeyMapping
Returns a new instance of KeyMapping.
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
#from ⇒ Object (readonly)
Returns the value of attribute from.
17 18 19 |
# File 'lib/burner/modeling/key_mapping.rb', line 17 def from @from end |
#to ⇒ Object (readonly)
Returns the value of attribute to.
17 18 19 |
# File 'lib/burner/modeling/key_mapping.rb', line 17 def to @to end |