class ArticleJSON::Elements::Embed
Attributes
caption[R]
embed_id[R]
embed_type[R]
Public Class Methods
new(embed_type:, embed_id:, caption:, tags: [])
click to toggle source
@param [Symbol] embed_type
@param [String] embed_id
@param [Array] caption @param [Array] tags
# File lib/article_json/elements/embed.rb, line 10 def initialize(embed_type:, embed_id:, caption:, tags: []) @type = :embed @embed_type = embed_type @embed_id = embed_id @caption = caption @tags = tags end
Private Class Methods
parse_hash(hash)
click to toggle source
Create an embedded element from Hash @return [ArticleJSON::Elements::Embed]
# File lib/article_json/elements/embed.rb, line 52 def parse_hash(hash) new( embed_type: hash[:embed_type], embed_id: hash[:embed_id], caption: parse_hash_list(hash[:caption]), tags: hash[:tags] ) end
Public Instance Methods
oembed_data()
click to toggle source
Obtain the oembed data for this embed element @return [Hash|nil]
# File lib/article_json/elements/embed.rb, line 32 def oembed_data oembed_resolver&.oembed_data end
to_h()
click to toggle source
Hash representation of this embedded element @return [Hash]
# File lib/article_json/elements/embed.rb, line 20 def to_h { type: type, embed_type: embed_type, embed_id: embed_id, tags: tags, caption: caption.map(&:to_h), } end
Private Instance Methods
oembed_resolver()
click to toggle source
@return [ArticleJSON::Utils::OEmbedResolver::Base]
# File lib/article_json/elements/embed.rb, line 44 def oembed_resolver @oembed_resolver ||= ArticleJSON::Utils::OEmbedResolver::Base.build(self) end