Class: PhotoUtils::Time
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_seconds(s) ⇒ Object
5
6
7
|
# File 'lib/photo_utils/time.rb', line 5
def self.new_from_seconds(s)
new(s)
end
|
.new_from_v(v) ⇒ Object
9
10
11
|
# File 'lib/photo_utils/time.rb', line 9
def self.new_from_v(v)
new(2 ** -v.to_f)
end
|
Instance Method Details
21
22
23
24
25
26
27
|
# File 'lib/photo_utils/time.rb', line 21
def format_seconds
if (seconds = to_seconds) < 1
'1/' + (1/self).format(1)
else
seconds.format
end + 's'
end
|
29
30
31
|
# File 'lib/photo_utils/time.rb', line 29
def format_value
"Tv:#{to_v.format(10)}"
end
|
#reciprocity ⇒ Object
46
47
48
49
|
# File 'lib/photo_utils/time.rb', line 46
def reciprocity
tc = self + (0.3 * (self ** 1.62))
Time.new(tc)
end
|
#to_s(format = :seconds) ⇒ Object
33
34
35
36
37
38
39
40
41
42
|
# File 'lib/photo_utils/time.rb', line 33
def to_s(format=:seconds)
case format
when :seconds
format_seconds
when :value
format_value
else
raise "Unknown format: #{format.inspect}"
end
end
|
#to_seconds ⇒ Object
17
18
19
|
# File 'lib/photo_utils/time.rb', line 17
def to_seconds
to_f
end
|
#to_v ⇒ Object
13
14
15
|
# File 'lib/photo_utils/time.rb', line 13
def to_v
-Math.log2(self.to_f)
end
|