Class: Exiftoolr::Parser

Inherits:
Object
  • Object
show all
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

Instance Method Summary collapse

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_keyObject (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_valueObject (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_keyObject (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

#valueObject



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.message}"
end