Class: ArticleJSON::Elements::Quote
- Defined in:
- lib/article_json/elements/quote.rb
Instance Attribute Summary collapse
-
#caption ⇒ Object
readonly
Returns the value of attribute caption.
-
#content ⇒ Object
readonly
Returns the value of attribute content.
-
#float ⇒ Object
readonly
Returns the value of attribute float.
Attributes inherited from Base
Class Method Summary collapse
-
.parse_hash(hash) ⇒ ArticleJSON::Elements::Quote
Create a quote element from Hash.
Instance Method Summary collapse
-
#initialize(content:, caption:, float: nil) ⇒ Quote
constructor
A new instance of Quote.
-
#to_h ⇒ Hash
Hash representation of this quote element.
Methods inherited from Base
Constructor Details
#initialize(content:, caption:, float: nil) ⇒ Quote
Returns a new instance of Quote.
9 10 11 12 13 14 |
# File 'lib/article_json/elements/quote.rb', line 9 def initialize(content:, caption:, float: nil) @type = :quote @content = content @caption = @float = float end |
Instance Attribute Details
#caption ⇒ Object (readonly)
Returns the value of attribute caption.
4 5 6 |
# File 'lib/article_json/elements/quote.rb', line 4 def @caption end |
#content ⇒ Object (readonly)
Returns the value of attribute content.
4 5 6 |
# File 'lib/article_json/elements/quote.rb', line 4 def content @content end |
#float ⇒ Object (readonly)
Returns the value of attribute float.
4 5 6 |
# File 'lib/article_json/elements/quote.rb', line 4 def float @float end |
Class Method Details
.parse_hash(hash) ⇒ ArticleJSON::Elements::Quote
Create a quote element from Hash
30 31 32 33 34 35 36 |
# 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 |
Instance Method Details
#to_h ⇒ Hash
Hash representation of this quote element
18 19 20 21 22 23 24 25 |
# File 'lib/article_json/elements/quote.rb', line 18 def to_h { type: type, float: float, content: content.map(&:to_h), caption: .map(&:to_h), } end |