Method: TimeCalc::Sequence#initialize

Defined in:
lib/time_calc/sequence.rb

#initialize(from:, to: nil, step: nil) ⇒ Sequence

Note:

Prefer TimeCalc#to or TimeCalc#step for producing sequences.

Returns a new instance of Sequence.

Parameters:

  • from (Time, Date, DateTime)
  • to (Time, Date, DateTime, nil) (defaults to: nil)

    ‘nil` produces endless sequence, which can be limited later with #to method.

  • step ((Integer, Symbol), nil) (defaults to: nil)

    Pair of span and unit to advance sequence; no ‘step` produces incomplete sequence (#each will raise), which can be completed later with #step method.



32
33
34
35
36
# File 'lib/time_calc/sequence.rb', line 32

def initialize(from:, to: nil, step: nil)
  @from = Value.wrap(from)
  @to = to&.then(&Value.method(:wrap))
  @step = step
end