Class: Unitwise::Functional

Inherits:
Scale
  • Object
show all
Extended by:
Math
Defined in:
lib/unitwise/functional.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Scale

#atoms, #depth, #inspect, #root_terms, #scalar, #special?, #terms, #to_s, #unit

Methods included from Compatible

#<=>, #compatible_with?, #composition, #composition_string, #dim, included

Constructor Details

#initialize(value, unit, function_name) ⇒ Functional

Returns a new instance of Functional.



47
48
49
50
# File 'lib/unitwise/functional.rb', line 47

def initialize(value, unit, function_name)
  @function_name = function_name
  super(value, unit)
end

Instance Attribute Details

#function_name ⇒ Object (readonly)

Returns the value of attribute function_name.



45
46
47
# File 'lib/unitwise/functional.rb', line 45

def function_name
  @function_name
end

Class Method Details

._2lg(x, forward = true) ⇒ Object



41
42
43
# File 'lib/unitwise/functional.rb', line 41

def self._2lg(x, forward = true)
  forward ? 2 * log10(x) : 10 ** ( x / 2 )
end

._cel(x, forward = true) ⇒ Object



5
6
7
# File 'lib/unitwise/functional.rb', line 5

def self._cel(x, forward=true)
  forward ? x - 273.15 : x + 273.15
end

._degf(x, forward = true) ⇒ Object



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

def self._degf(x, forward=true)
  forward ? 9.0 * x / 5.0 - 459.67 : 5.0 / 9 * (x + 459.67)
end

._hpC(x, forward = true) ⇒ Object



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

def self._hpC(x, forward=true)
  forward ? -log(x) / log(100) : 100 ** -x 
end

._hpX(x, forward = true) ⇒ Object



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

def self._hpX(x, forward=true)
  forward ? -log10(x) : 10 ** -x
end

._ld(x, forward = true) ⇒ Object



29
30
31
# File 'lib/unitwise/functional.rb', line 29

def self._ld(x, forward=true)
  forward ? log2(x) : 2 ** x
end

._lg(x, forward = true) ⇒ Object



37
38
39
# File 'lib/unitwise/functional.rb', line 37

def self._lg(x, forward = true)
  forward ? log10(x) : 10 ** x
end

._ln(x, forward = true) ⇒ Object



33
34
35
# File 'lib/unitwise/functional.rb', line 33

def self._ln(x, forward=true)
  forward ? log(x) : Math::E ** x
end

._ph(x, forward = true) ⇒ Object



25
26
27
# File 'lib/unitwise/functional.rb', line 25

def self._ph(x, forward=true)
  _hpX(x,forward)
end

._tan100(x, forward = true) ⇒ Object



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

def self._tan100(x, forward=true)
  forward ? 100 * tan(x) : atan(x / 100)
end

Instance Method Details

#functional(x = scalar, forward = true) ⇒ Object



52
53
54
# File 'lib/unitwise/functional.rb', line 52

def functional(x=scalar, forward = true)
  self.class.send(:"_#{function_name}", x, forward)
end