Class: FormatParser::EXIFParser::EXIFResult
- Inherits:
-
SimpleDelegator
- Object
- SimpleDelegator
- FormatParser::EXIFParser::EXIFResult
- Defined in:
- lib/parsers/exif_parser.rb
Instance Attribute Summary collapse
-
#sub_ifds_data ⇒ Object
readonly
Returns the value of attribute sub_ifds_data.
Instance Method Summary collapse
-
#initialize(exif_raw_data, sub_ifds_data = {}) ⇒ EXIFResult
constructor
A new instance of EXIFResult.
- #orientation ⇒ Object
- #orientation_sym ⇒ Object
- #rotated? ⇒ Boolean
- #to_json(*maybe_coder) ⇒ Object
Constructor Details
#initialize(exif_raw_data, sub_ifds_data = {}) ⇒ EXIFResult
Returns a new instance of EXIFResult.
46 47 48 49 |
# File 'lib/parsers/exif_parser.rb', line 46 def initialize(exif_raw_data, sub_ifds_data = {}) super(exif_raw_data) @sub_ifds_data = sub_ifds_data end |
Instance Attribute Details
#sub_ifds_data ⇒ Object (readonly)
Returns the value of attribute sub_ifds_data.
44 45 46 |
# File 'lib/parsers/exif_parser.rb', line 44 def sub_ifds_data @sub_ifds_data end |
Instance Method Details
#orientation ⇒ Object
61 62 63 64 65 66 67 |
# File 'lib/parsers/exif_parser.rb', line 61 def orientation # In some EXIF tags the value type is set oddly - it unpacks into multiple values, # and it will look like this: [#<EXIFR::TIFF::Orientation:TopLeft(1)>, nil] orientation_values = Array(__getobj__.orientation) last_usable_value = orientation_values.compact[-1] # Use the last non-nil one last_usable_value.to_i end |
#orientation_sym ⇒ Object
69 70 71 |
# File 'lib/parsers/exif_parser.rb', line 69 def orientation_sym ORIENTATIONS.fetch(orientation) end |
#rotated? ⇒ Boolean
51 52 53 |
# File 'lib/parsers/exif_parser.rb', line 51 def rotated? orientation.to_i > 4 end |
#to_json(*maybe_coder) ⇒ Object
55 56 57 58 59 |
# File 'lib/parsers/exif_parser.rb', line 55 def to_json(*maybe_coder) hash_representation = __getobj__.to_hash sanitized = FormatParser::AttributesJSON._sanitize_json_value(hash_representation) sanitized.to_json(*maybe_coder) end |