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