Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Implementing conversion for rational values.

  • Loading branch information...
commit f5a8187f2ff6eddb0828b2d179848e8fe8f67550 1 parent f218515
janfri authored
Showing with 13 additions and 0 deletions.
  1. +2 −0  lib/mini_exiftool.rb
  2. +1 −0  test/test_read.rb
  3. +10 −0 test/test_write.rb
2  lib/mini_exiftool.rb
View
@@ -345,6 +345,8 @@ def parse_line line
# nothing => String
when /^-?\d+$/
value = value.to_i
+ when %r(^\d+/\d+$)
+ value = Rational(value)
when /^[\d ]+$/
# nothing => String
when /#{@@separator}/
1  test/test_read.rb
View
@@ -31,6 +31,7 @@ def test_conversion
assert_kind_of String, (@mini_exiftool['SubjectLocation'] || @mini_exiftool['SubjectArea'])
assert_kind_of Array, @mini_exiftool['Keywords']
assert_kind_of String, @mini_exiftool['SupplementalCategories']
+ assert_kind_of Rational, @mini_exiftool.shutterspeed
end
def test_list_tags
10 test/test_write.rb
View
@@ -109,6 +109,16 @@ def test_integer_conversion
assert_equal new_mode, @mini_exiftool_num['MeteringMode']
end
+ def test_rational_conversion
+ new_exposure_time = Rational(1, 125)
+ @mini_exiftool.exposure_time = new_exposure_time
+ assert @mini_exiftool.changed?, 'No changing of value.'
+ ok = @mini_exiftool.save
+ assert ok, 'Saving failed.'
+ @mini_exiftool.reload
+ assert_equal new_exposure_time, @mini_exiftool.exposure_time
+ end
+
def test_list_conversion
arr = ['a', 'b', 'c']
@mini_exiftool['Keywords'] = arr
Please sign in to comment.
Something went wrong with that request. Please try again.