Class: Enumerable::Position

Inherits:
Object show all
Defined in:
lib/core/facets/enumerable/with_position.rb

Instance Method Summary collapse

Constructor Details

#initializePosition

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

Returns:

  • (Boolean)


17
18
19
# File 'lib/core/facets/enumerable/with_position.rb', line 17

def first?
	@first
end

#last?Boolean

Returns:

  • (Boolean)


25
26
27
# File 'lib/core/facets/enumerable/with_position.rb', line 25

def last?
	@last
end

#middle?Boolean

Returns:

  • (Boolean)


21
22
23
# File 'lib/core/facets/enumerable/with_position.rb', line 21

def middle?
	not (@first or @last)
end