Module: Enumerable
- Defined in:
- lib/each_with_flag/enumerable/each_with_flag.rb
Constant Summary collapse
- EACH_WITH_FLAG_VERSION =
The version of the each-with-flag library.
'0.1.0'- EACH_WITH_FLAG_FLAGS =
{ :first => [:first, :is_first], :has_previous => [:has_previous, :has_prev], :surrounded => [:surrounded, :is_surrounded], :has_next => :has_next, :last => [:last, :is_last] }
Instance Method Summary collapse
Instance Method Details
#each_with_flag(*params) ⇒ Object
13 14 15 16 17 |
# File 'lib/each_with_flag/enumerable/each_with_flag.rb', line 13 def each_with_flag(*params) self.each_with_index do |data, index| yield data, *flags(index, params) end end |
#each_with_index_with_flag(*params) ⇒ Object
19 20 21 22 23 |
# File 'lib/each_with_flag/enumerable/each_with_flag.rb', line 19 def each_with_index_with_flag(*params) self.each_with_index do |data, index| yield data, index, *flags(index, params) end end |