class MLBGameday::Team

Attributes

city[R]
code[R]
division[R]
file_code[R]
id[R]
league[R]
name[R]

Public Class Methods

new(opts = {}) click to toggle source
# File lib/mlb_gameday/team.rb, line 7
def initialize(opts = {})
  @id        = opts[:id]
  @name      = opts[:name]
  @city      = opts[:city]
  @league    = opts[:league]
  @division  = opts[:division]
  @alt_names = opts[:alt_names]
  @code      = opts[:code]
  @file_code = opts[:file_code]
end

Public Instance Methods

called?(name) click to toggle source
# File lib/mlb_gameday/team.rb, line 26
def called?(name)
  names.include?(name.downcase)
end
full_name() click to toggle source
# File lib/mlb_gameday/team.rb, line 18
def full_name
  "#{city} #{name}"
end
inspect() click to toggle source

So we don't get huge printouts

# File lib/mlb_gameday/team.rb, line 31
def inspect
  %(#<MLBGameday::Team @name="#{@name}">)
end
names() click to toggle source
# File lib/mlb_gameday/team.rb, line 22
def names
  @names ||= (implicit_names + alt_names).uniq
end

Private Instance Methods

alt_names() click to toggle source
# File lib/mlb_gameday/team.rb, line 37
def alt_names
  @alt_names ||= []
end
despaced_name() click to toggle source
# File lib/mlb_gameday/team.rb, line 57
def despaced_name
  name.tr ' ', ''
end
implicit_names() click to toggle source
# File lib/mlb_gameday/team.rb, line 41
def implicit_names
  result = strict_names
  result << [code, singular_name, despaced_name].map(&:downcase)
  result << city.downcase unless ['New York', 'Chicago'].include?(city)

  result.flatten.uniq
end
singular_name() click to toggle source
# File lib/mlb_gameday/team.rb, line 53
def singular_name
  name.chomp 's'
end
strict_names() click to toggle source
# File lib/mlb_gameday/team.rb, line 49
def strict_names
  [name, full_name].map(&:downcase)
end