Class: Burner::Library::Collection::Number
- Inherits:
-
JobWithRegister
- Object
- Job
- JobWithRegister
- Burner::Library::Collection::Number
- Defined in:
- lib/burner/library/collection/number.rb
Overview
Constant Summary collapse
- BLANK =
''
- DEFAULT_KEY =
'number'
- DEFAULT_START_AT =
1
Instance Attribute Summary collapse
-
#key ⇒ Object
readonly
Returns the value of attribute key.
-
#resolver ⇒ Object
readonly
Returns the value of attribute resolver.
-
#start_at ⇒ Object
readonly
Returns the value of attribute start_at.
Attributes inherited from JobWithRegister
Attributes inherited from Job
Instance Method Summary collapse
-
#initialize(key: DEFAULT_KEY, name: BLANK, register: Burner::DEFAULT_REGISTER, separator: BLANK, start_at: DEFAULT_START_AT) ⇒ Number
constructor
A new instance of Number.
- #perform(output, payload) ⇒ Object
Methods included from Util::Arrayable
Constructor Details
#initialize(key: DEFAULT_KEY, name: BLANK, register: Burner::DEFAULT_REGISTER, separator: BLANK, start_at: DEFAULT_START_AT) ⇒ Number
Returns a new instance of Number.
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/burner/library/collection/number.rb', line 25 def initialize( key: DEFAULT_KEY, name: BLANK, register: Burner::DEFAULT_REGISTER, separator: BLANK, start_at: DEFAULT_START_AT ) super(name: name, register: register) @key = key.to_s @resolver = Objectable.resolver(separator: separator) @start_at = start_at.to_i freeze end |
Instance Attribute Details
#key ⇒ Object (readonly)
Returns the value of attribute key.
23 24 25 |
# File 'lib/burner/library/collection/number.rb', line 23 def key @key end |
#resolver ⇒ Object (readonly)
Returns the value of attribute resolver.
23 24 25 |
# File 'lib/burner/library/collection/number.rb', line 23 def resolver @resolver end |
#start_at ⇒ Object (readonly)
Returns the value of attribute start_at.
23 24 25 |
# File 'lib/burner/library/collection/number.rb', line 23 def start_at @start_at end |
Instance Method Details
#perform(output, payload) ⇒ Object
41 42 43 44 45 46 47 |
# File 'lib/burner/library/collection/number.rb', line 41 def perform(output, payload) output.detail("Setting '#{key}' for each record with values starting at #{start_at}") ensure_array(payload).each.with_index(start_at) do |record, index| resolver.set(record, key, index) end end |