Class: TimeBoots::Lace
- Inherits:
-
Object
- Object
- TimeBoots::Lace
- Defined in:
- lib/time_boots/lace.rb
Instance Attribute Summary collapse
-
#from ⇒ Object
readonly
Returns the value of attribute from.
-
#to ⇒ Object
readonly
Returns the value of attribute to.
Instance Method Summary collapse
- #expand ⇒ Object
- #expand! ⇒ Object
-
#initialize(step, from, to, options = {}) ⇒ Lace
constructor
A new instance of Lace.
- #inspect ⇒ Object
- #pull(beginnings = false) ⇒ Object
- #pull_pairs(beginnings = false) ⇒ Object
- #pull_ranges(beginnings = false) ⇒ Object
Constructor Details
Instance Attribute Details
#from ⇒ Object (readonly)
Returns the value of attribute from.
12 13 14 |
# File 'lib/time_boots/lace.rb', line 12 def from @from end |
#to ⇒ Object (readonly)
Returns the value of attribute to.
12 13 14 |
# File 'lib/time_boots/lace.rb', line 12 def to @to end |
Instance Method Details
#expand ⇒ Object
21 22 23 |
# File 'lib/time_boots/lace.rb', line 21 def dup.tap(&:expand!) end |
#expand! ⇒ Object
14 15 16 17 18 19 |
# File 'lib/time_boots/lace.rb', line 14 def @from = boot.floor(from) @to = boot.ceil(to) self end |
#inspect ⇒ Object
47 48 49 |
# File 'lib/time_boots/lace.rb', line 47 def inspect "#<#{self.class}(#{from} - #{to})>" end |
#pull(beginnings = false) ⇒ Object
25 26 27 28 29 30 31 32 33 34 35 36 |
# 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) ⇒ Object
38 39 40 41 |
# 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) ⇒ Object
43 44 45 |
# File 'lib/time_boots/lace.rb', line 43 def pull_ranges(beginnings = false) pull_pairs(beginnings).map { |b, e| (b...e) } end |