class ArticleJSON::Elements::Quote

Attributes

caption[R]
content[R]
float[R]

Public Class Methods

new(content:, caption:, float: nil) click to toggle source

@param [Array] content @param [Array] caption @param [Symbol] float

# File lib/article_json/elements/quote.rb, line 9
def initialize(content:, caption:, float: nil)
  @type = :quote
  @content = content
  @caption = caption
  @float = float
end
parse_hash(hash) click to toggle source

Create a quote element from Hash @return [ArticleJSON::Elements::Quote]

# File lib/article_json/elements/quote.rb, line 30
def parse_hash(hash)
  new(
    content: parse_hash_list(hash[:content]),
    caption: parse_hash_list(hash[:caption]),
    float: hash[:float]&.to_sym
  )
end

Public Instance Methods

to_h() click to toggle source

Hash representation of this quote element @return [Hash]

# File lib/article_json/elements/quote.rb, line 18
def to_h
  {
    type: type,
    float: float,
    content: content.map(&:to_h),
    caption: caption.map(&:to_h),
  }
end