Class: Hash
Instance Method Summary collapse
-
#each_with_end_flag ⇒ Object
This method iterates over the Array as normal #each method.
- #not_empty? ⇒ Boolean
Instance Method Details
#each_with_end_flag ⇒ Object
This method iterates over the Array as normal #each method. For each iteration set two variables in the block, |item, flag|. item will be set tot he current item in the iteration; flag will be set to “false” on all iterations except the last iteration
10 11 12 13 14 15 |
# File 'lib/corelib/hash/core.rb', line 10 def each_with_end_flag my_size = self.size self.each_with_index do |item, index| index + 1 == my_size ? yield(item, true) : yield(item, false) end end |
#not_empty? ⇒ Boolean
3 4 5 |
# File 'lib/corelib/hash/core.rb', line 3 def not_empty? !self.empty? end |