Permalink
Browse files

Extract a function that extracts xhtml uris as a method

  • Loading branch information...
1 parent b90d9e7 commit e76e638ebaddebee38b65008a12d1a7ead4adc91 @co-me co-me committed Jun 18, 2013
Showing with 10 additions and 4 deletions.
  1. +10 −4 epub-searcher.rb
View
@@ -3,19 +3,25 @@
require 'bundler'
Bundler.require
-def open_epub(filename)
+def extract_xhtml_uri_array(epub_book)
uri_array = Array.new
- epub_book = EPUB::Parser.parse(filename)
- metadata = epub_book.metadata
- # xhtml ドキュメントがどの順番で出てくるか記録する
epub_book.each_page_on_spine do |item|
if item.media_type == "application/xhtml+xml"
uri = item.href
uri_array << uri.to_s
end
end
+ return uri_array
+end
+
+def open_epub(filename)
+ epub_book = EPUB::Parser.parse(filename)
+ metadata = epub_book.metadata
+
+ uri_array = extract_xhtml_uri_array(epub_book)
+
Zip::Archive.open(filename) do |files|
entry_name_array = Array.new(uri_array.size)
files.num_files.times do |i|

0 comments on commit e76e638

Please sign in to comment.