Class: Ortfodb::ImageDimensions
- Inherits:
-
Dry::Struct
- Object
- Dry::Struct
- Ortfodb::ImageDimensions
- Defined in:
- lib/ortfodb/database.rb
Overview
ImageDimensions represents metadata about a media as it’s extracted from its file.
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.from_dynamic!(d) ⇒ Object
118 119 120 121 122 123 124 125 |
# File 'lib/ortfodb/database.rb', line 118 def self.from_dynamic!(d) d = Types::Hash[d] new( aspect_ratio: d.fetch("aspectRatio"), height: d.fetch("height"), width: d.fetch("width"), ) end |
.from_json!(json) ⇒ Object
127 128 129 |
# File 'lib/ortfodb/database.rb', line 127 def self.from_json!(json) from_dynamic!(JSON.parse(json)) end |
Instance Method Details
#to_dynamic ⇒ Object
131 132 133 134 135 136 137 |
# File 'lib/ortfodb/database.rb', line 131 def to_dynamic { "aspectRatio" => aspect_ratio, "height" => height, "width" => width, } end |
#to_json(options = nil) ⇒ Object
139 140 141 |
# File 'lib/ortfodb/database.rb', line 139 def to_json( = nil) JSON.generate(to_dynamic, ) end |