Class: ContinuousRange

Inherits:
Object
  • Object
show all
Defined in:
lib/ranges.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(range) ⇒ ContinuousRange

Returns a new instance of ContinuousRange.



4
5
6
7
# File 'lib/ranges.rb', line 4

def initialize(range)
	@minimum = range[:minimum]
	@maximum = range[:maximum]
end

Instance Attribute Details

#maximumObject

Returns the value of attribute maximum.



2
3
4
# File 'lib/ranges.rb', line 2

def maximum
  @maximum
end

#minimumObject

Returns the value of attribute minimum.



2
3
4
# File 'lib/ranges.rb', line 2

def minimum
  @minimum
end

Instance Method Details

#index(element) ⇒ Object



13
14
15
# File 'lib/ranges.rb', line 13

def index(element)
	element.to_f
end

#intervalObject



9
10
11
# File 'lib/ranges.rb', line 9

def interval
	@maximum - @minimum
end

#run(interval) ⇒ Object



17
18
19
20
21
22
23
# File 'lib/ranges.rb', line 17

def run(interval)
	current = @minimum
	while(current <= @maximum)
		yield(current,current)
		current += interval
	end
end