Class: PhotoUtils::Sensitivity
- Inherits:
-
Value
show all
- Defined in:
- lib/photo_utils/sensitivity.rb
Constant Summary
collapse
- C =
3.125
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_iso(n) ⇒ Object
7
8
9
|
# File 'lib/photo_utils/sensitivity.rb', line 7
def self.new_from_iso(n)
new(n)
end
|
.new_from_v(v) ⇒ Object
11
12
13
|
# File 'lib/photo_utils/sensitivity.rb', line 11
def self.new_from_v(v)
new(C * (2 ** v.to_f))
end
|
Instance Method Details
23
24
25
|
# File 'lib/photo_utils/sensitivity.rb', line 23
def format_iso
'ISO ' + to_iso.format(10)
end
|
27
28
29
|
# File 'lib/photo_utils/sensitivity.rb', line 27
def format_value
"Sv:#{to_v.format}"
end
|
#to_iso ⇒ Object
19
20
21
|
# File 'lib/photo_utils/sensitivity.rb', line 19
def to_iso
to_f
end
|
#to_s(format = :iso) ⇒ Object
31
32
33
34
35
36
37
38
39
40
|
# File 'lib/photo_utils/sensitivity.rb', line 31
def to_s(format=:iso)
case format
when :iso
format_iso
when :value
format_value
else
raise "Unknown format: #{format.inspect}"
end
end
|
#to_v ⇒ Object
15
16
17
|
# File 'lib/photo_utils/sensitivity.rb', line 15
def to_v
Math.log2(self / C)
end
|