Class: Numeric

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

Instance Method Summary collapse

Instance Method Details

#scale(from: 0, to: 0) ⇒ Object



5
6
7
8
9
10
11
12
# File 'lib/hueshift.rb', line 5

def scale(from: 0, to: 0)
  from_min = from.first
  from_max = from.last
  to_min   = to.first
  to_max   = to.last

  ((to_max - to_min) * (self - from_min)) / (from_max - from_min) + to_min
end