Skip to content
This repository
Browse code

Implementing conversion for rational values.

  • Loading branch information...
commit f5a8187f2ff6eddb0828b2d179848e8fe8f67550 1 parent f218515
janfri authored April 13, 2012
2  lib/mini_exiftool.rb
@@ -345,6 +345,8 @@ def parse_line line
345 345
         # nothing => String
346 346
       when /^-?\d+$/
347 347
         value = value.to_i
  348
+      when %r(^\d+/\d+$)
  349
+        value = Rational(value)
348 350
       when /^[\d ]+$/
349 351
         # nothing => String
350 352
       when /#{@@separator}/
1  test/test_read.rb
@@ -31,6 +31,7 @@ def test_conversion
31 31
     assert_kind_of String, (@mini_exiftool['SubjectLocation'] || @mini_exiftool['SubjectArea'])
32 32
     assert_kind_of Array, @mini_exiftool['Keywords']
33 33
     assert_kind_of String, @mini_exiftool['SupplementalCategories']
  34
+    assert_kind_of Rational, @mini_exiftool.shutterspeed
34 35
   end
35 36
 
36 37
   def test_list_tags
10  test/test_write.rb
@@ -109,6 +109,16 @@ def test_integer_conversion
109 109
     assert_equal new_mode, @mini_exiftool_num['MeteringMode']
110 110
   end
111 111
 
  112
+  def test_rational_conversion
  113
+    new_exposure_time = Rational(1, 125)
  114
+    @mini_exiftool.exposure_time = new_exposure_time
  115
+    assert @mini_exiftool.changed?, 'No changing of value.'
  116
+    ok = @mini_exiftool.save
  117
+    assert ok, 'Saving failed.'
  118
+    @mini_exiftool.reload
  119
+    assert_equal new_exposure_time, @mini_exiftool.exposure_time
  120
+  end
  121
+
112 122
   def test_list_conversion
113 123
     arr =  ['a', 'b', 'c']
114 124
     @mini_exiftool['Keywords'] = arr

0 notes on commit f5a8187

Please sign in to comment.
Something went wrong with that request. Please try again.