Class: Beckett::Document

Inherits:
Object
  • Object
show all
Defined in:
lib/beckett.rb

Instance Method Summary collapse

Constructor Details

#initialize(content) ⇒ Document

Returns a new instance of Document.



21
22
23
# File 'lib/beckett.rb', line 21

def initialize(content)
  @content = content
end

Instance Method Details

#to_hashObject



25
26
27
28
29
# File 'lib/beckett.rb', line 25

def to_hash
  document = Kramdown::Document.new(@content, input: 'GFM')
  renderer = Renderer.send(:new, document.root)
  renderer.convert(document.root)
end

#to_jsonObject



31
32
33
# File 'lib/beckett.rb', line 31

def to_json
  to_hash.to_json
end