Class: Scale::Source::Range

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

Overview

Contains logic for dealing with Ruby’s core ::Range as input

Instance Method Summary collapse

Constructor Details

#initialize(range) ⇒ Range

Returns a new instance of Range.

Parameters:

  • range (::Range)

    A range to operate on



12
13
14
# File 'lib/scale/source.rb', line 12

def initialize(range)
  @range = range
end

Instance Method Details

#denominatorFloat

Returns:

  • (Float)


23
24
25
# File 'lib/scale/source.rb', line 23

def denominator
  (@range.last - @range.first).abs.to_f
end

#numerator(input) ⇒ Float

Parameters:

Returns:

  • (Float)


18
19
20
# File 'lib/scale/source.rb', line 18

def numerator(input)
  (input - @range.first).to_f
end