class ArticleJSON::Elements::List

Attributes

content[R]
list_type[R]

Public Class Methods

new(content:, list_type: :unordered) click to toggle source

@param [Array] content @param [Symbol] list_type

# File lib/article_json/elements/list.rb, line 8
def initialize(content:, list_type: :unordered)
  @type = :list
  @content = content
  @list_type = list_type
end
parse_hash(hash) click to toggle source

Create a list element from Hash @return [ArticleJSON::Elements::List]

# 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

Public Instance Methods

to_h() click to toggle source

Hash representation of this heading element @return [Hash]

# File lib/article_json/elements/list.rb, line 16
def to_h
  {
    type: type,
    list_type: list_type,
    content: content.map(&:to_h),
  }
end