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.
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) ⇒ 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) ⇒ TextBox
Returns a new instance of TextBox.
8 9 10 11 12 |
# File 'lib/article_json/elements/text_box.rb', line 8 def initialize(content:, float: nil) @type = :text_box @content = content @float = float 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 |
Class Method Details
.parse_hash(hash) ⇒ ArticleJSON::Elements::TextBox
Create a text box element from Hash
27 28 29 30 31 32 |
# File 'lib/article_json/elements/text_box.rb', line 27 def parse_hash(hash) new( content: parse_hash_list(hash[:content]), float: hash[:float]&.to_sym ) end |
Instance Method Details
#to_h ⇒ Hash
Hash representation of this text box element
16 17 18 19 20 21 22 |
# File 'lib/article_json/elements/text_box.rb', line 16 def to_h { type: type, float: float, content: content.map(&:to_h), } end |