5 def initialize(fileName)
13 parseFileName!(fileName)
16 def self.canHandle?(fileName)
21 lowerName = fileName.downcase()
23 if lowerName.end_with?(".epub")
33 data.push('author="' + @author + '"')
36 data.push('series="' + @series + '"')
39 data.push('volume="' + @volume + '"')
42 data.push('title="' + @title + '"')
45 data.push('path="' + @path + '"')
47 return '(Book:' + data.join(',') + ')'
56 return /[[:upper:]]/.match(c)
60 def massageAuthor(input)
66 input.each_char do |c|
67 if isUpper?(c) and (result.length > 0)
76 # Returns (series, volumeNo, titleText)
78 def processTitle(input)
83 arr = input.split('_')
89 matchData = (arr[0]).match(/^([A-Z]+)([0-9]+)$/)
91 capt = matchData.captures
97 pos = arr[-1].rindex('.')
99 arr[-1] = arr[-1].slice(0, pos)
102 title = arr.join(' ')
104 return series, vol, title
108 def parseFileName!(fileName)
109 parts = fileName.split('/')
110 (@series, @volume, @title) = processTitle(parts[-1])
112 @author = massageAuthor(parts[-2])