Class: AhlScraper::Seasons::Team

Inherits:
Resource
  • Object
show all
Defined in:
lib/ahl_scraper/resources/seasons/team.rb

Constant Summary collapse

EXCEPTIONS =
{
  "albany-river-rats" => { city: "Albany", name: "River Rats" },
  "bridgeport-sound-tigers" => { city: "Bridgeport", name: "Sound Tigers" },
  "grand-rapids-griffins" => { city: "Grand Rapids", name: "Griffins", abbreviation: "GR" },
  "hartford-wolf-pack" => { city: "Hartford", name: "Wolf Pack" },
  "lake-erie-monsters" => { city: "Lake Erie", name: "Monsters" },
  "lowell-lock-monsters" => { city: "Lowell", name: "Lock Monsters" },
  "lehigh-valley-phantoms" => { city: "Lehigh Valley", name: "Phantoms" },
  "manitoba-moose" => { city: "Manitoba", name: "Moose", abbreviation: "MB" },
  "oklahoma-city-barons" => { city: "Oklahoma City", name: "Barons" },
  "omaha-ak-sar-ben-knights" => { city: "Omaha", name: "Ak-Sar-Ben Knights" },
  "quad-city-flames" => { city: "Quad City", name: "Flames" },
  "san-antonio-rampage" => { city: "San Antonio", name: "Rampage" },
  "san-diego-gulls" => { city: "San Diego", name: "Gulls" },
  "san-jose-barracuda" => { city: "San Jose", name: "Barracuda" },
  "st-john-s-icecaps" => { city: "St. John's", name: "IceCaps" },
  "st-john-s-maple-leafs" => { city: "St. John's", name: "Maple Leafs" },
  "cincinnati-mighty-ducks" => { city: "Cincinnati", name: "Mighty Ducks" },
  "wilkes-barre-scranton-penguins" => { city: "Wilkes-Barre/Scranton", name: "Penguins", game_file_city: "W-B/Scranton" },
  "edmonton-road-runners" => { city: "Edmonton", name: "Road Runners" },
  "henderson-silver-knights" => { city: "Henderson", name: "Silver Knights" },
  "coachella-valley-firebirds" => { city: "Coachella Valley", name: "Firebirds" },
}.freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Resource

#[], #each, #inspect, #keys, #to_json, #values

Constructor Details

#initialize(raw_data, division, opts = {}) ⇒ Team

Returns a new instance of Team.



32
33
34
35
# File 'lib/ahl_scraper/resources/seasons/team.rb', line 32

def initialize(raw_data, division, opts = {})
  super(raw_data, opts)
  @division = division
end

Instance Attribute Details

#divisionObject (readonly)

Returns the value of attribute division.



6
7
8
# File 'lib/ahl_scraper/resources/seasons/team.rb', line 6

def division
  @division
end

Instance Method Details

#abbreviationObject



45
46
47
48
# File 'lib/ahl_scraper/resources/seasons/team.rb', line 45

def abbreviation
  @abbreviation ||= EXCEPTIONS[parameterized_name]&.dig(:abbreviation) || @raw_data.dig(:row,
    :team_code)&.delete_prefix("y -")&.delete_prefix("x -")&.delete_prefix("xy -")&.strip
end

#cityObject



54
55
56
# File 'lib/ahl_scraper/resources/seasons/team.rb', line 54

def city
  @city ||= full_name&.split.length > 2 ? exception_split_object&.dig(:city) : full_name&.split[0]
end

#full_nameObject



41
42
43
# File 'lib/ahl_scraper/resources/seasons/team.rb', line 41

def full_name
  @full_name ||= @raw_data.dig(:row, :name)&.delete_prefix("y -")&.delete_prefix("x -")&.delete_prefix("xy -")&.strip
end

#game_file_cityObject



62
63
64
# File 'lib/ahl_scraper/resources/seasons/team.rb', line 62

def game_file_city
  @game_file_city ||= EXCEPTIONS[parameterized_name]&.dig(:game_file_city)
end

#idObject



37
38
39
# File 'lib/ahl_scraper/resources/seasons/team.rb', line 37

def id
  @id ||= @raw_data.dig(:prop, :team_code, :teamLink)&.to_i
end

#nameObject



58
59
60
# File 'lib/ahl_scraper/resources/seasons/team.rb', line 58

def name
  @name ||= full_name&.split.length > 2 ? exception_split_object&.dig(:name) : full_name&.split[1]
end

#parameterized_nameObject



50
51
52
# File 'lib/ahl_scraper/resources/seasons/team.rb', line 50

def parameterized_name
  @parameterized_name ||= ParameterizeHelper.new(full_name).call
end