Class: Burner::Library::Value::Copy
- Defined in:
- lib/burner/library/value/copy.rb
Overview
Copy one value in a register to another. Note that this does not perform any type of deep copy, it simply points one register’s value to another. If you decide to later mutate one register then you may mutate the other.
Expected Payload input: anything. Payload output: whatever value was specified in the from_register.
Instance Attribute Summary collapse
-
#from_register ⇒ Object
readonly
Returns the value of attribute from_register.
-
#to_register ⇒ Object
readonly
Returns the value of attribute to_register.
Attributes inherited from Job
Instance Method Summary collapse
-
#initialize(from_register: DEFAULT_REGISTER, name: '', to_register: DEFAULT_REGISTER) ⇒ Copy
constructor
A new instance of Copy.
- #perform(output, payload) ⇒ Object
Methods included from Util::Arrayable
Constructor Details
#initialize(from_register: DEFAULT_REGISTER, name: '', to_register: DEFAULT_REGISTER) ⇒ Copy
Returns a new instance of Copy.
22 23 24 25 26 27 28 29 |
# File 'lib/burner/library/value/copy.rb', line 22 def initialize(from_register: DEFAULT_REGISTER, name: '', to_register: DEFAULT_REGISTER) super(name: name) @from_register = from_register.to_s @to_register = to_register.to_s freeze end |
Instance Attribute Details
#from_register ⇒ Object (readonly)
Returns the value of attribute from_register.
20 21 22 |
# File 'lib/burner/library/value/copy.rb', line 20 def from_register @from_register end |
#to_register ⇒ Object (readonly)
Returns the value of attribute to_register.
20 21 22 |
# File 'lib/burner/library/value/copy.rb', line 20 def to_register @to_register end |
Instance Method Details
#perform(output, payload) ⇒ Object
31 32 33 34 35 |
# File 'lib/burner/library/value/copy.rb', line 31 def perform(output, payload) output.detail("Copying register: '#{from_register}' to: '#{to_register}'") payload[to_register] = payload[from_register] end |