Class: PhotoUtils::Illuminance
- Inherits:
-
Value
show all
- Defined in:
- lib/photo_utils/illuminance.rb
Constant Summary
collapse
- N =
2 ** Rational(-7, 4)
- C =
224
- NC =
N * C
Class Method Summary
collapse
Instance Method Summary
collapse
Methods inherited from Value
#<=>, #==, #decr, #incr, #initialize
Methods inherited from Float
#format, #prec
Class Method Details
.new_from_lux(lux) ⇒ Object
11
12
13
|
# File 'lib/photo_utils/illuminance.rb', line 11
def self.new_from_lux(lux)
new(lux)
end
|
.new_from_v(v) ⇒ Object
15
16
17
|
# File 'lib/photo_utils/illuminance.rb', line 15
def self.new_from_v(v)
new((2 ** v.to_f) * NC)
end
|
Instance Method Details
27
28
29
|
# File 'lib/photo_utils/illuminance.rb', line 27
def format_lux
to_lux.format(10) + ' lux'
end
|
31
32
33
|
# File 'lib/photo_utils/illuminance.rb', line 31
def format_value
"Iv:#{to_v.format(10)}"
end
|
#to_lux ⇒ Object
23
24
25
|
# File 'lib/photo_utils/illuminance.rb', line 23
def to_lux
to_f
end
|
#to_s(format = :lux) ⇒ Object
35
36
37
38
39
40
41
42
43
44
|
# File 'lib/photo_utils/illuminance.rb', line 35
def to_s(format=:lux)
case format
when :lux
format_lux
when :value
format_value
else
raise "Unknown format: #{format.inspect}"
end
end
|
#to_v ⇒ Object
19
20
21
|
# File 'lib/photo_utils/illuminance.rb', line 19
def to_v
Math.log2(self / NC)
end
|