Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Remove implementing of to_a in serval cases, use Array method instead.

  • Loading branch information...
commit 4b0ff33e22bc961efce71378ba5a822a93d1fc8f 1 parent 1b5a0b0
@janfri authored
View
8 Tutorial
@@ -53,7 +53,7 @@ Following types of values are at the moment supported:
* Time (e. g. DateTimeOriginal => 2005:09:13 20:08:50)
Be aware, if there is only one value in a tag which can hold multiple
-values the result is'nt an array! But you can get one with the to_a
+values the result is'nt an array! But you can get one with the Array
method:
# only _one_ keyword
p1 = MiniExiftool.new 'p1.jpg'
@@ -63,9 +63,9 @@ method:
p3.keywords # => ['red', 'yellow', 'green']
# if we want to get an array in both cases and don't know
- # if there is one ore more values set let's take to_a
- p1.keywords.to_a # => ['red']
- p3.keywords.to_a # => ['red', 'yellow', 'green']
+ # if there is one ore more values set let's take Array()
+ Array(p1.keywords) # => ['red']
+ Array(p3.keywords) # => ['red', 'yellow', 'green']
The Exiftool command-line application has an option (-n) to get values
as numbers if possible, in MiniExiftool you can do this with setting
View
16 lib/mini_exiftool.rb
@@ -349,13 +349,6 @@ def parse_line line
else
raise MiniExiftool::Error.new("Malformed line #{line.inspect} of exiftool output.")
end
- unless value.respond_to?('to_a')
- class << value
- def to_a
- [self]
- end
- end
- end
return [tag, value]
end
@@ -440,14 +433,5 @@ def unify tag
end
-# Add to_a to Numerical if it's not yet defined
-unless Numeric.instance_methods.include? 'to_a'
- class Numeric
- def to_a
- [self]
- end
- end
-end
-
# Test if we can run the Exiftool command
MiniExiftool.exiftool_version
View
3  test/test_read.rb
@@ -31,13 +31,12 @@ 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 Array, @mini_exiftool['SupplementalCategories'].to_a
end
def test_list_tags
assert_equal ['Orange', 'Rot'], @mini_exiftool['Keywords']
assert_equal 'Natur', @mini_exiftool['SupplementalCategories']
- assert_equal ['Natur'], @mini_exiftool['SupplementalCategories'].to_a
+ assert_equal ['Natur'], Array(@mini_exiftool['SupplementalCategories'])
end
def test_encoding_conversion
View
1  test/test_read_numerical.rb
@@ -28,7 +28,6 @@ def test_conversion_numerical
assert_kind_of String, (@mini_exiftool_num['SubjectLocation'] || @mini_exiftool_num['SubjectArea'])
assert_kind_of Array, @mini_exiftool_num['Keywords']
assert_kind_of String, @mini_exiftool_num['SupplementalCategories']
- assert_kind_of Array, @mini_exiftool_num['SupplementalCategories'].to_a
end
end
Please sign in to comment.
Something went wrong with that request. Please try again.