Module: NFLTeams
- Defined in:
- lib/nfl_teams.rb,
lib/nfl_teams/data.rb
Defined Under Namespace
Modules: Data
Class Method Summary collapse
- .abbreviation(location_or_name) ⇒ Object
- .all ⇒ Object
- .full_names ⇒ Object
- .search(string) ⇒ Object
Class Method Details
.abbreviation(location_or_name) ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/nfl_teams.rb', line 13 def self.abbreviation(location_or_name) team_by_name = NFLTeams::Data::TEAMS.find { |t| t[:name] == location_or_name } return team_by_name[:abbreviation] if team_by_name teams_by_location = NFLTeams::Data::TEAMS.find_all { |t| t[:location] == location_or_name } abbrv_location = teams_by_location.map { |t| t[:abbreviation] } return abbrv_location.first if abbrv_location.size == 1 return abbrv_location if abbrv_location.size > 1 nil end |