Class: AozoraSsml::Document

Inherits:
Object
  • Object
show all
Defined in:
lib/aozora-ssml/document.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(title, author, main_text) ⇒ Document

Returns a new instance of Document.



15
16
17
18
19
# File 'lib/aozora-ssml/document.rb', line 15

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

Instance Attribute Details

#authorObject (readonly)

Returns the value of attribute author.



5
6
7
# File 'lib/aozora-ssml/document.rb', line 5

def author
  @author
end

#main_textObject (readonly)

Returns the value of attribute main_text.



5
6
7
# File 'lib/aozora-ssml/document.rb', line 5

def main_text
  @main_text
end

#titleObject (readonly)

Returns the value of attribute title.



5
6
7
# File 'lib/aozora-ssml/document.rb', line 5

def title
  @title
end

Class Method Details

.parse(html) ⇒ Object



7
8
9
10
11
12
13
# File 'lib/aozora-ssml/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
  new(title, author, main_text)
end