Class: Range

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

Overview

Copyright muflax <[email protected]>, 2011 License: GNU GPL 3 <www.gnu.org/copyleft/gpl.html>

Instance Method Summary collapse

Instance Method Details

#%(other) ⇒ Object



12
# File 'lib/range_math.rb', line 12

def %(other) 	; pair_or_num :%, other     	; end

#*(other) ⇒ Object



9
# File 'lib/range_math.rb', line 9

def *(other) 	; pair_or_num :*, other     	; end

#**(other) ⇒ Object



11
# File 'lib/range_math.rb', line 11

def **(other)	; pair_or_num :**, other    	; end

#+(other) ⇒ Object



7
# File 'lib/range_math.rb', line 7

def +(other) 	; pair_or_num :+, other     	; end

#-(other) ⇒ Object



8
# File 'lib/range_math.rb', line 8

def -(other) 	; pair_or_num :-, other     	; end

#/(other) ⇒ Object



10
# File 'lib/range_math.rb', line 10

def /(other) 	; pair_or_num :/, other.to_f	; end

#averageObject



21
22
23
# File 'lib/range_math.rb', line 21

def average
  (self.begin + self.end) / 2.0
end

#coerce(other) ⇒ Object



25
26
27
28
29
30
31
32
# File 'lib/range_math.rb', line 25

def coerce(other)
  case other
  when Range  	; return other, self
  when Numeric	; return (other..other), self
  else
    super
  end
end

#round(places = 0) ⇒ Object



17
18
19
# File 'lib/range_math.rb', line 17

def round places=0
  (self.begin.round(places)..self.end.round(places))
end

#to_fObject



14
# File 'lib/range_math.rb', line 14

def to_f	; (self.begin.to_f..self.end.to_f)  	; end

#to_iObject



15
# File 'lib/range_math.rb', line 15

def to_i	; (self.begin.round..self.end.round)	; end