Class: ArticleJSON::Elements::List
- Defined in:
- lib/article_json/elements/list.rb
Instance Attribute Summary collapse
-
#content ⇒ Object
readonly
Returns the value of attribute content.
-
#list_type ⇒ Object
readonly
Returns the value of attribute list_type.
Attributes inherited from Base
Class Method Summary collapse
-
.parse_hash(hash) ⇒ ArticleJSON::Elements::List
Create a list element from Hash.
Instance Method Summary collapse
-
#initialize(content:, list_type: :unordered) ⇒ List
constructor
A new instance of List.
-
#to_h ⇒ Hash
Hash representation of this heading element.
Methods inherited from Base
Constructor Details
#initialize(content:, list_type: :unordered) ⇒ List
Returns a new instance of List.
8 9 10 11 12 |
# File 'lib/article_json/elements/list.rb', line 8 def initialize(content:, list_type: :unordered) @type = :list @content = content @list_type = list_type end |
Instance Attribute Details
#content ⇒ Object (readonly)
Returns the value of attribute content.
4 5 6 |
# File 'lib/article_json/elements/list.rb', line 4 def content @content end |
#list_type ⇒ Object (readonly)
Returns the value of attribute list_type.
4 5 6 |
# File 'lib/article_json/elements/list.rb', line 4 def list_type @list_type end |
Class Method Details
.parse_hash(hash) ⇒ ArticleJSON::Elements::List
Create a list element from Hash
27 28 29 30 31 32 |
# File 'lib/article_json/elements/list.rb', line 27 def parse_hash(hash) new( content: parse_hash_list(hash[:content]), list_type: hash[:list_type].to_sym ) end |
Instance Method Details
#to_h ⇒ Hash
Hash representation of this heading element
16 17 18 19 20 21 22 |
# File 'lib/article_json/elements/list.rb', line 16 def to_h { type: type, list_type: list_type, content: content.map(&:to_h), } end |