Class: PhotoUtils::Aperture
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_fstop(f) ⇒ Object
5
6
7
|
# File 'lib/photo_utils/aperture.rb', line 5
def self.new_from_fstop(f)
new(f)
end
|
.new_from_v(v) ⇒ Object
9
10
11
|
# File 'lib/photo_utils/aperture.rb', line 9
def self.new_from_v(v)
new(Math.sqrt(2 ** v.to_f))
end
|
Instance Method Details
#absolute(focal_length) ⇒ Object
56
57
58
|
# File 'lib/photo_utils/aperture.rb', line 56
def absolute(focal_length)
focal_length / self
end
|
17
18
19
20
21
22
23
24
25
|
# File 'lib/photo_utils/aperture.rb', line 17
def format_fstop(stop_steps=3)
rounded_f = Aperture.new_from_v((to_v.to_f * stop_steps).to_i / stop_steps.to_f).format(10)
frac = rounded_f.to_f - rounded_f.to_i
if frac != 0
"f/#{rounded_f.to_f}"
else
"f/#{rounded_f.to_i}"
end
end
|
27
28
29
30
31
32
33
34
35
36
37
|
# File 'lib/photo_utils/aperture.rb', line 27
def format_us
steps = to_v.to_i - 8
us = 16
if steps < 0
steps.abs.times { us /= 2 }
else
steps.times { us *= 2 }
end
"US #{us}"
end
|
39
40
41
|
# File 'lib/photo_utils/aperture.rb', line 39
def format_value
"Av:#{to_v.format(10)}"
end
|
#to_s(format = :fstop, stop_steps = 3) ⇒ Object
43
44
45
46
47
48
49
50
51
52
53
54
|
# File 'lib/photo_utils/aperture.rb', line 43
def to_s(format=:fstop, stop_steps=3)
case format
when :us
format_us
when :fstop
format_fstop(stop_steps)
when :value
format_value
else
raise "Unknown format: #{format.inspect}"
end
end
|
#to_v ⇒ Object
13
14
15
|
# File 'lib/photo_utils/aperture.rb', line 13
def to_v
Math.log2(self ** 2)
end
|