Class: ThinModels::LazyArray::Mapped
Instance Method Summary
collapse
#[], #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
#each ⇒ Object
125
126
127
|
# File 'lib/thin_models/lazy_array.rb', line 125
def each
@underlying.each {|x| yield @block.call(x)}
end
|
#length ⇒ Object
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
|