Class: Range::Seq
- Includes:
- Apricot::Seq
- Defined in:
- lib/apricot/ruby_ext.rb
Instance Method Summary collapse
- #each ⇒ Object
- #first ⇒ Object
-
#initialize(first, last, exclusive) ⇒ Seq
constructor
A new instance of Seq.
- #next ⇒ Object
Methods included from Apricot::Seq
#<=>, #cons, #empty?, #hash, #last, #rest, #to_s, #to_seq
Methods included from Enumerable
Constructor Details
#initialize(first, last, exclusive) ⇒ Seq
Returns a new instance of Seq.
193 194 195 196 197 |
# File 'lib/apricot/ruby_ext.rb', line 193 def initialize(first, last, exclusive) @first = first @last = last @exclusive = exclusive end |
Instance Method Details
#each ⇒ Object
213 214 215 216 217 218 219 220 221 222 223 224 |
# File 'lib/apricot/ruby_ext.rb', line 213 def each prev = nil val = @first until prev == @last || (val == @last && @exclusive) yield val prev = val val = val.succ end self end |
#first ⇒ Object
199 200 201 |
# File 'lib/apricot/ruby_ext.rb', line 199 def first @first end |