Class: Aozoragen::SaiZenSenShort

Inherits:
SaiZenSen show all
Defined in:
lib/aozoragen/sai-zen-sen.rb

Instance Method Summary collapse

Methods inherited from SaiZenSen

#each_chapter_local, #get_chapter_text

Methods included from Util

#detag

Constructor Details

#initialize(index_uri) ⇒ SaiZenSenShort

Returns a new instance of SaiZenSenShort.



99
100
101
102
# File 'lib/aozoragen/sai-zen-sen.rb', line 99

def initialize( index_uri )
	@index_uri = index_uri
	@index_html = Nokogiri( open( @index_uri, 'r:utf-8', &:read ) )
end

Instance Method Details

#each_chapter {|{id: Pathname( @index_uri.path ).basename( '.html' ).to_s, uri: @index_uri, text: text}| ... } ⇒ Object

Yields:

  • ({id: Pathname( @index_uri.path ).basename( '.html' ).to_s, uri: @index_uri, text: text})


113
114
115
116
# File 'lib/aozoragen/sai-zen-sen.rb', line 113

def each_chapter
	text = get_chapter_text( @index_html )
	yield( {id: Pathname( @index_uri.path ).basename( '.html' ).to_s, uri: @index_uri, text: text} )
end

#metainfoObject



104
105
106
107
108
109
110
111
# File 'lib/aozoragen/sai-zen-sen.rb', line 104

def metainfo
	info = {:id => Pathname( @index_uri.path ).dirname.dirname.basename.to_s, :author => []}
	info[:title] = (@index_html / 'h1.book-title')[0].text
	(@index_html / 'h2.book-author strong').each do |author|
		info[:author] << author.text
	end
	info
end