class Burner::Library::Collection::Shift
Take an array and remove the first N elements, where N is specified by the amount attribute. The initial use case for this was to remove “header” rows from arrays, like you would expect when parsing CSV files.
Expected Payload input: nothing. Payload output: An array with N beginning elements removed.
Constants
- DEFAULT_AMOUNT
Attributes
amount[R]
Public Class Methods
new(amount: DEFAULT_AMOUNT, name: '', register: DEFAULT_REGISTER)
click to toggle source
Calls superclass method
Burner::JobWithRegister::new
# File lib/burner/library/collection/shift.rb, line 26 def initialize(amount: DEFAULT_AMOUNT, name: '', register: DEFAULT_REGISTER) super(name: name, register: register) @amount = amount.to_i freeze end
Public Instance Methods
perform(output, payload)
click to toggle source
# File lib/burner/library/collection/shift.rb, line 34 def perform(output, payload) output.detail("Shifting #{amount} entries.") payload[register] = array(payload[register]).slice(amount..-1) end