Sha256: f8439ec422e10d965bc5afc9076874da4e50a1c0f65a0d39a1ebe32c1c5ece37

Contents?: true

Size: 508 Bytes

Versions: 2

Compression:

Stored size: 508 Bytes

Contents

require "nokogiri"
require "htmlentities"

module AozoraSsml
  class Document
    attr_reader :title, :author, :main_text

    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
      new(title, author, main_text)
    end

    def initialize(title, author, main_text)
      @title = title
      @author = author
      @main_text = main_text
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
aozora-ssml-0.1.1 lib/aozora-ssml/document.rb
aozora-ssml-0.1.0 lib/aozora-ssml/document.rb