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

Constructor Details

This class inherits a constructor from PhotoUtils::Value

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

#format_isoObject



23
24
25
# File 'lib/photo_utils/sensitivity.rb', line 23

def format_iso
  'ISO ' + to_iso.format(10)
end

#format_valueObject



27
28
29
# File 'lib/photo_utils/sensitivity.rb', line 27

def format_value
  "Sv:#{to_v.format}"
end

#to_isoObject



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_vObject



15
16
17
# File 'lib/photo_utils/sensitivity.rb', line 15

def to_v
  Math.log2(self / C)
end