Class: PhotoUtils::Compensation
- Inherits:
-
Value
show all
- Defined in:
- lib/photo_utils/compensation.rb
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_factor(f) ⇒ Object
amount specified in factor
7
8
9
|
# File 'lib/photo_utils/compensation.rb', line 7
def self.new_from_factor(f)
new(f)
end
|
.new_from_v(v) ⇒ Object
11
12
13
|
# File 'lib/photo_utils/compensation.rb', line 11
def self.new_from_v(v)
new(2 ** v)
end
|
Instance Method Details
23
24
25
|
# File 'lib/photo_utils/compensation.rb', line 23
def format_factor
"x%.1f" % to_f.format(10)
end
|
27
28
29
30
31
32
33
|
# File 'lib/photo_utils/compensation.rb', line 27
def format_value
v = to_v
"Cv:%s%s" % [
(v < 0) ? '-' : '+',
v.abs.format(10)
]
end
|
#to_factor ⇒ Object
15
16
17
|
# File 'lib/photo_utils/compensation.rb', line 15
def to_factor
to_f
end
|
#to_s(format = :factor) ⇒ Object
35
36
37
38
39
40
41
42
43
44
|
# File 'lib/photo_utils/compensation.rb', line 35
def to_s(format=:factor)
case format
when :factor
format_factor
when :value
format_value
else
raise "Unknown format: #{format.inspect}"
end
end
|
#to_v ⇒ Object
19
20
21
|
# File 'lib/photo_utils/compensation.rb', line 19
def to_v
Math.log2(to_f)
end
|