Class: Aozoragen::SaiZenSenShort
- Defined in:
- lib/aozoragen/sai-zen-sen.rb
Instance Method Summary collapse
- #each_chapter {|{id: Pathname( @index_uri.path ).basename( '.html' ).to_s, uri: @index_uri, text: text}| ... } ⇒ Object
-
#initialize(index_uri) ⇒ SaiZenSenShort
constructor
A new instance of SaiZenSenShort.
- #metainfo ⇒ Object
Methods inherited from SaiZenSen
#each_chapter_local, #get_chapter_text
Methods included from Util
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
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 |
#metainfo ⇒ Object
104 105 106 107 108 109 110 111 |
# File 'lib/aozoragen/sai-zen-sen.rb', line 104 def 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 || info[:author] << .text end info end |