class TimeBoots::Lace

Attributes

boot[R]
from[R]
to[R]

Public Class Methods

new(step, from, to, options = {}) click to toggle source
# File lib/time_boots/lace.rb, line 4
def initialize(step, from, to, options = {})
  @boot = Boot.get(step)
  @from, @to = from, to
  @options = options.dup

  expand! if options[:expand]
end

Public Instance Methods

expand() click to toggle source
# File lib/time_boots/lace.rb, line 21
def expand
  dup.tap(&:expand!)
end
expand!() click to toggle source
# File lib/time_boots/lace.rb, line 14
def expand!
  @from = boot.floor(from)
  @to = boot.ceil(to)

  self
end
inspect() click to toggle source
# File lib/time_boots/lace.rb, line 47
def inspect
  "#<#{self.class}(#{from} - #{to})>"
end
pull(beginnings = false) click to toggle source
# File lib/time_boots/lace.rb, line 25
def pull(beginnings = false)
  seq = []

  iter = from
  while iter < to
    seq << iter

    iter = cond_floor(boot.advance(iter), beginnings)
  end

  seq
end
pull_pairs(beginnings = false) click to toggle source
# File lib/time_boots/lace.rb, line 38
def pull_pairs(beginnings = false)
  seq = pull(beginnings)
  seq.zip(seq[1..-1] + [to])
end
pull_ranges(beginnings = false) click to toggle source
# File lib/time_boots/lace.rb, line 43
def pull_ranges(beginnings = false)
  pull_pairs(beginnings).map { |b, e| (b...e) }
end

Private Instance Methods

cond_floor(tm, should_floor) click to toggle source
# File lib/time_boots/lace.rb, line 53
def cond_floor(tm, should_floor)
  should_floor ? boot.floor(tm) : tm
end