class ShowNameInterpreter
A class that can be used to parse a series of show names into an array of ShowEpisodes
objects. To use this class, add shows using addName, then call processNames to get the result.
Public Class Methods
new()
click to toggle source
# File plugins/shows/lib/showname_parse.rb, line 184 def initialize @names = [] @metaInfo = [] end
Public Instance Methods
addName(name, metaInfo = nil)
click to toggle source
# File plugins/shows/lib/showname_parse.rb, line 189 def addName(name, metaInfo = nil) @names.push name @metaInfo.push metaInfo end
processNames()
click to toggle source
Process the episode names added with addName and return a Hsah of ShowEpisodes
objects, keyed by show name.
# File plugins/shows/lib/showname_parse.rb, line 195 def processNames shows = {} i = 0 @names.each{ |n| parsedArray = ParsedShowName.parse(n, @metaInfo[i]) parsedArray.each{ |parsed| episodes = shows[parsed.showName] if ! episodes episodes = ShowEpisodes.new episodes.showName = parsed.showName shows[parsed.showName] = episodes end episode = ShowEpisode.new episode.season = parsed.season episode.episode = parsed.episode episodes.episodes.push episode } i += 1 } shows end