class ArticleJSON::Elements::Heading

Attributes

content[R]
level[R]

Public Class Methods

new(level:, content:) click to toggle source

@param [String] level @param [String] content

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

Create a heading element from Hash @return [ArticleJSON::Elements::Heading]

# File lib/article_json/elements/heading.rb, line 27
def parse_hash(hash)
  new(
    level: hash[:level].to_i,
    content: hash[:content]
  )
end

Public Instance Methods

to_h() click to toggle source

Hash representation of this heading element @return [Hash]

# File lib/article_json/elements/heading.rb, line 16
def to_h
  {
    type: type,
    level: level,
    content: content,
  }
end