class IML::Text

Parsing and mangling of text metadata

Attributes

options[RW]

Public Class Methods

new(string = nil, options = {}) click to toggle source
Calls superclass method
# File lib/iml/text.rb, line 7
def initialize(string = nil, options = {})
  @options = options
  super(string.to_s)
end

Public Instance Methods

detect() click to toggle source

Determine if IML::Text matches rules for a media type @return [<IML::Movie>, <IML::TVSeries>] Media type object

# File lib/iml/text.rb, line 19
def detect
  tv? || movie? || false
end
to_title() click to toggle source

Convert IML::Text to desired title format

# File lib/iml/text.rb, line 13
def to_title
  tr('.', ' ').tr('_', ' ').titleize
end

Private Instance Methods

match_and_return(pattern) click to toggle source
# File lib/iml/text.rb, line 43
def match_and_return(pattern)
  match = self.match(pattern)
  if match
    match.named_captures
  else
    false
  end
end
match_patterns(patterns) click to toggle source
# File lib/iml/text.rb, line 35
def match_patterns(patterns)
  patterns.each do |pattern|
    match = match_and_return(pattern)
    return match if match
  end
  false
end
movie?() click to toggle source
# File lib/iml/text.rb, line 30
def movie?
  match = match_patterns(IML::Patterns.new.movie)
  match ? IML::Movie.new(match, options) : false
end
tv?() click to toggle source
# File lib/iml/text.rb, line 25
def tv?
  match = match_patterns(IML::Patterns.new.tv)
  match ? IML::TVSeries.new(match, options) : false
end