lib/nhl/team.rb
# Search for a specific team either by id or name.
Search for a specific team either by id or name.
Search for a specific team either by id or name .
def find(query)
        id = query.to_i
        if id == 0
          response = Faraday.get(URL)
          data = JSON.parse(response.body)
          t = data[KEY].find do |t|
            t['name'] == query
          end
        else
          response = Faraday.get("#{URL}/#{id}")
          data = JSON.parse(response.body)
          t = data['teams'].first if data['teams']
        end
        new(t) if t
      end
def find ( query ) id = query . to_i if id == 0 response = Faraday . get ( URL ) data = JSON . parse ( response . body ) t = data [ KEY ] . find do | t | t [ 'name' ] == query end else response = Faraday . get ( "#{URL}/#{id}" ) data = JSON . parse ( response . body ) t = data [ 'teams' ] . first if data [ 'teams' ] end new ( t ) if t end
Search for a specific team either by id or name.
Search for a specific team either by id or name .
query
<not_specific>