Class: Enumerable::Position
- Defined in:
- lib/core/facets/enumerable/with_position.rb
Instance Method Summary collapse
- #after_first! ⇒ Object
- #at_end! ⇒ Object
- #first? ⇒ Boolean
-
#initialize ⇒ Position
constructor
A new instance of Position.
- #last? ⇒ Boolean
- #middle? ⇒ Boolean
Constructor Details
#initialize ⇒ Position
Returns a new instance of Position.
4 5 6 7 |
# File 'lib/core/facets/enumerable/with_position.rb', line 4 def initialize @first = true @last = false end |
Instance Method Details
#after_first! ⇒ Object
9 10 11 |
# File 'lib/core/facets/enumerable/with_position.rb', line 9 def after_first! @first = false end |
#at_end! ⇒ Object
13 14 15 |
# File 'lib/core/facets/enumerable/with_position.rb', line 13 def at_end! @last = true end |
#first? ⇒ Boolean
17 18 19 |
# File 'lib/core/facets/enumerable/with_position.rb', line 17 def first? @first end |
#last? ⇒ Boolean
25 26 27 |
# File 'lib/core/facets/enumerable/with_position.rb', line 25 def last? @last end |
#middle? ⇒ Boolean
21 22 23 |
# File 'lib/core/facets/enumerable/with_position.rb', line 21 def middle? not (@first or @last) end |