class AozoraPolly::Document

Attributes

author[R]
bibliography[R]
main_text[R]
title[R]

Public Class Methods

new(title, author, main_text, bibliography) click to toggle source
# File lib/aozora_polly/document.rb, line 16
def initialize(title, author, main_text, bibliography)
  @title = title
  @author = author
  @main_text = main_text
  @bibliography = bibliography
end
parse(html) click to toggle source
# File lib/aozora_polly/document.rb, line 7
def self.parse(html)
  doc = Nokogiri::HTML.parse(html)
  title = doc.xpath('//h1').text
  author = doc.xpath('//h2').text
  main_text = doc.xpath('//div[@class="main_text"]').to_html
  bibliography = doc.xpath('//div[@class="bibliographical_information"]').to_html
  new(title, author, main_text, bibliography)
end