class Kamishibai::Book

Attributes

author[RW]
bookcode[RW]
fullpath[R]
fullpath_valid[RW]
inode[RW]
itime[RW]
mtime[RW]
page[RW]
pages[RW]
rtime[RW]
size[RW]
title[RW]

Public Class Methods

new(bookcode=nil, fullpath=nil) click to toggle source
# File lib/kamishibai/book.rb, line 47
def initialize(bookcode=nil, fullpath=nil)
        if bookcode and fullpath
                @bookcode = bookcode
                @fullpath = fullpath
                if File.exists?( fullpath )
                        fs = File.stat( fullpath )
                        @mtime = fs.mtime.to_i

                        # mark the path as valid, aka book exists in path
                        @fullpath_valid = true
                end

                # create book title
                title = File.basename( fullpath )
                title.gsub!(/_/,' ')
                title.gsub!(/ /u,' ')
                title.gsub!(/\(.+?\)/,'')
                @author = title.scan(/\[(.+?)\]/)[0][0] if title.scan(/\[(.+?)\]/)[0] and title.scan(/\[(.+?)\]/)[0][0]
                title.gsub!(/\[.+?\]/,'')
                #title.gsub!(/ \S\d+.*/,'')
                title.gsub!(/ \d{4}\S[\d\.]+.+/,'')
                title.gsub!(/ (v|c|第)[\d\.]+.*/iu,'')
                title.gsub!(/ vol.{0,2}[\d\.]+.*/i,'')
                title.gsub!(/ (上|中|下)\.cbz/iu,'.cbz')
                title.gsub!(/ \#[\d\.]+.*/i,'')
                title.gsub!(/ ch.{0,2}[\d\.]+.*/i,'')
                title.gsub!(/ +/,' ')
                title.gsub!(/^ /,'')
                title.gsub!(/\.cbz$/,'')
                title.gsub!(/ $/,'')
                title.gsub!(/ [\d\.]+$/,'')
                @title = title

                @itime = Time.now.to_i
                @pages = cbz_pages?( @fullpath )

                unless @pages
                        puts "Book contain no images! #{fullpath}"
                end
        end
end

Public Instance Methods

fullpath=(newfullpath) click to toggle source
# File lib/kamishibai/book.rb, line 89
def fullpath=(newfullpath)
        @fullpath = newfullpath

        if File.exists?(newfullpath)
                @fullpath_valid = true
        end
end