Class: Exiftool::Parser
- Inherits:
-
Object
- Object
- Exiftool::Parser
- Defined in:
- lib/exiftool/parser.rb
Constant Summary collapse
- WORD_BOUNDARY_RES =
[/([A-Z\d]+)([A-Z][a-z])/, /([a-z\d])([A-Z])/]
- FRACTION_RE =
/^(\d+)\/(\d+)$/
Instance Attribute Summary collapse
-
#display_key ⇒ Object
readonly
Returns the value of attribute display_key.
-
#key ⇒ Object
readonly
Returns the value of attribute key.
-
#raw_value ⇒ Object
readonly
Returns the value of attribute raw_value.
-
#sym_key ⇒ Object
readonly
Returns the value of attribute sym_key.
Instance Method Summary collapse
-
#initialize(key, raw_value) ⇒ Parser
constructor
A new instance of Parser.
- #value ⇒ Object
Constructor Details
#initialize(key, raw_value) ⇒ Parser
Returns a new instance of Parser.
12 13 14 15 16 17 |
# File 'lib/exiftool/parser.rb', line 12 def initialize(key, raw_value) @key = key @display_key = WORD_BOUNDARY_RES.inject(key) { |k, regex| k.gsub(regex, '\1 \2') } @sym_key = display_key.downcase.gsub(' ', '_').to_sym @raw_value = raw_value end |
Instance Attribute Details
#display_key ⇒ Object (readonly)
Returns the value of attribute display_key.
10 11 12 |
# File 'lib/exiftool/parser.rb', line 10 def display_key @display_key end |
#key ⇒ Object (readonly)
Returns the value of attribute key.
10 11 12 |
# File 'lib/exiftool/parser.rb', line 10 def key @key end |
#raw_value ⇒ Object (readonly)
Returns the value of attribute raw_value.
10 11 12 |
# File 'lib/exiftool/parser.rb', line 10 def raw_value @raw_value end |
#sym_key ⇒ Object (readonly)
Returns the value of attribute sym_key.
10 11 12 |
# File 'lib/exiftool/parser.rb', line 10 def sym_key @sym_key end |
Instance Method Details
#value ⇒ Object
19 20 21 22 23 24 25 26 |
# File 'lib/exiftool/parser.rb', line 19 def value for_lat_long || for_date || for_fraction || raw_value rescue StandardError => e "Warning: Parsing '#{raw_value}' for attribute '#{key}' raised #{e.}" end |