Class: ThinModels::LazyArray::Mapped

Inherits:
ThinModels::LazyArray show all
Defined in:
lib/thin_models/lazy_array.rb

Instance Method Summary collapse

Methods inherited from ThinModels::LazyArray

#[], #empty?, #first, #inspect, #join, #last, #map, #size, #to_json

Constructor Details

#initialize(underlying, &block) ⇒ Mapped

Returns a new instance of Mapped.



121
122
123
# File 'lib/thin_models/lazy_array.rb', line 121

def initialize(underlying, &block)
  @underlying = underlying; @block = block
end

Instance Method Details

#eachObject



125
126
127
# File 'lib/thin_models/lazy_array.rb', line 125

def each
  @underlying.each {|x| yield @block.call(x)}
end

#lengthObject



129
130
131
# File 'lib/thin_models/lazy_array.rb', line 129

def length
  @underlying.length
end

#slice_from_start_and_length(start, length) ⇒ Object



133
134
135
# File 'lib/thin_models/lazy_array.rb', line 133

def slice_from_start_and_length(start, length)
  @underlying.slice_from_start_and_length(start, length).map(&@block)
end