Class: Exiftoolr::Parser
- Inherits:
-
Object
- Object
- Exiftoolr::Parser
- Defined in:
- lib/exiftoolr/result.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.
-
#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.
40 41 42 43 44 |
# File 'lib/exiftoolr/result.rb', line 40 def initialize(key, raw_value) @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.
38 39 40 |
# File 'lib/exiftoolr/result.rb', line 38 def display_key @display_key end |
#raw_value ⇒ Object (readonly)
Returns the value of attribute raw_value.
38 39 40 |
# File 'lib/exiftoolr/result.rb', line 38 def raw_value @raw_value end |
#sym_key ⇒ Object (readonly)
Returns the value of attribute sym_key.
38 39 40 |
# File 'lib/exiftoolr/result.rb', line 38 def sym_key @sym_key end |
Instance Method Details
#value ⇒ Object
46 47 48 49 50 51 52 53 |
# File 'lib/exiftoolr/result.rb', line 46 def value for_lat_long || for_date || for_fraction || raw_value rescue StandardError => e v = "Warning: Parsing '#{raw_value}' for attribute '#{k}' raised #{e.}" end |