Class: Ortfodb::ContentBlock
- Inherits:
-
Dry::Struct
- Object
- Dry::Struct
- Ortfodb::ContentBlock
- Defined in:
- lib/ortfodb/database.rb
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.from_dynamic!(d) ⇒ Object
208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 |
# File 'lib/ortfodb/database.rb', line 208 def self.from_dynamic!(d) d = Types::Hash[d] new( alt: d.fetch("alt"), analyzed: d.fetch("analyzed"), anchor: d.fetch("anchor"), attributes: MediaAttributes.from_dynamic!(d.fetch("attributes")), caption: d.fetch("caption"), colors: ColorPalette.from_dynamic!(d.fetch("colors")), content: d.fetch("content"), content_type: d.fetch("contentType"), dimensions: ImageDimensions.from_dynamic!(d.fetch("dimensions")), dist_source: d.fetch("distSource"), duration: d.fetch("duration"), content_block_hash: d.fetch("hash"), has_sound: d.fetch("hasSound"), id: d.fetch("id"), index: d.fetch("index"), online: d.fetch("online"), relative_source: d.fetch("relativeSource"), size: d.fetch("size"), text: d.fetch("text"), thumbnails: ThumbnailsMap.from_dynamic!(d.fetch("thumbnails")), thumbnails_built_at: d.fetch("thumbnailsBuiltAt"), title: d.fetch("title"), content_block_type: d.fetch("type"), url: d.fetch("url"), ) end |
.from_json!(json) ⇒ Object
238 239 240 |
# File 'lib/ortfodb/database.rb', line 238 def self.from_json!(json) from_dynamic!(JSON.parse(json)) end |
Instance Method Details
#to_dynamic ⇒ Object
242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 |
# File 'lib/ortfodb/database.rb', line 242 def to_dynamic { "alt" => alt, "analyzed" => analyzed, "anchor" => anchor, "attributes" => attributes.to_dynamic, "caption" => caption, "colors" => colors.to_dynamic, "content" => content, "contentType" => content_type, "dimensions" => dimensions.to_dynamic, "distSource" => dist_source, "duration" => duration, "hash" => content_block_hash, "hasSound" => has_sound, "id" => id, "index" => index, "online" => online, "relativeSource" => relative_source, "size" => size, "text" => text, "thumbnails" => thumbnails.to_dynamic, "thumbnailsBuiltAt" => thumbnails_built_at, "title" => title, "type" => content_block_type, "url" => url, } end |
#to_json(options = nil) ⇒ Object
271 272 273 |
# File 'lib/ortfodb/database.rb', line 271 def to_json( = nil) JSON.generate(to_dynamic, ) end |