Class: ArticleJSON::Elements::Embed
- Defined in:
- lib/article_json/elements/embed.rb
Instance Attribute Summary collapse
-
#caption ⇒ Object
readonly
Returns the value of attribute caption.
-
#embed_id ⇒ Object
readonly
Returns the value of attribute embed_id.
-
#embed_type ⇒ Object
readonly
Returns the value of attribute embed_type.
-
#tags ⇒ Object
readonly
Returns the value of attribute tags.
Attributes inherited from Base
Class Method Summary collapse
-
.parse_hash(hash) ⇒ ArticleJSON::Elements::Embed
Create an embedded element from Hash.
Instance Method Summary collapse
-
#initialize(embed_type:, embed_id:, caption:, tags: []) ⇒ Embed
constructor
A new instance of Embed.
-
#oembed_data ⇒ Hash|nil
Obtain the oembed data for this embed element.
- #oembed_unavailable_message ⇒ Array[ArticleJSON::Elements::Text]|nil
-
#to_h ⇒ Hash
Hash representation of this embedded element.
Methods inherited from Base
Constructor Details
#initialize(embed_type:, embed_id:, caption:, tags: []) ⇒ Embed
Returns a new instance of Embed.
10 11 12 13 14 15 16 |
# File 'lib/article_json/elements/embed.rb', line 10 def initialize(embed_type:, embed_id:, caption:, tags: []) @type = :embed @embed_type = @embed_id = @caption = @tags = end |
Instance Attribute Details
#caption ⇒ Object (readonly)
Returns the value of attribute caption.
4 5 6 |
# File 'lib/article_json/elements/embed.rb', line 4 def @caption end |
#embed_id ⇒ Object (readonly)
Returns the value of attribute embed_id.
4 5 6 |
# File 'lib/article_json/elements/embed.rb', line 4 def @embed_id end |
#embed_type ⇒ Object (readonly)
Returns the value of attribute embed_type.
4 5 6 |
# File 'lib/article_json/elements/embed.rb', line 4 def @embed_type end |
#tags ⇒ Object (readonly)
Returns the value of attribute tags.
4 5 6 |
# File 'lib/article_json/elements/embed.rb', line 4 def @tags end |
Class Method Details
.parse_hash(hash) ⇒ ArticleJSON::Elements::Embed
Create an embedded element from Hash
52 53 54 55 56 57 58 59 |
# 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 |
Instance Method Details
#oembed_data ⇒ Hash|nil
Obtain the oembed data for this embed element
32 33 34 |
# File 'lib/article_json/elements/embed.rb', line 32 def &. end |
#oembed_unavailable_message ⇒ Array[ArticleJSON::Elements::Text]|nil
37 38 39 |
# File 'lib/article_json/elements/embed.rb', line 37 def &. end |
#to_h ⇒ Hash
Hash representation of this embedded element
20 21 22 23 24 25 26 27 28 |
# File 'lib/article_json/elements/embed.rb', line 20 def to_h { type: type, embed_type: , embed_id: , tags: , caption: .map(&:to_h), } end |