class SportsDataApi::Ncaafb::Polls
Attributes
candidates[R]
id[R]
name[R]
rankings[R]
season[R]
season_type[R]
week[R]
Public Class Methods
new(polls_hash)
click to toggle source
# File lib/sports_data_api/ncaafb/polls.rb, line 7 def initialize(polls_hash) @id = polls_hash['id'] @name = polls_hash['name'] @season = polls_hash['season'] @season_type = polls_hash['season_type'] @week = polls_hash['week'] @rankings = [] @candidates = [] add_poll_teams_to(@rankings, polls_hash['rankings']) add_poll_teams_to(@candidates, polls_hash['candidates']) end
valid_name?(poll)
click to toggle source
Check if the requested poll is a valid Ncaafb
poll type.
The only valid polls are: :AP25, :EU25, :CFP25, :FCSC25, :H25, :FCS25
# File lib/sports_data_api/ncaafb/polls.rb, line 37 def valid_name?(poll) [:AP25, :EU25, :CFP25, :FCSC25, :H25, :FCS25].include?(poll.upcase.to_sym) end
valid_week?(week)
click to toggle source
The only valid week nr is 1..21
# File lib/sports_data_api/ncaafb/polls.rb, line 42 def valid_week?(week) (1..21).include?(week.to_i) end
Public Instance Methods
each() { |team| ... }
click to toggle source
Make the class Enumerable
# File lib/sports_data_api/ncaafb/polls.rb, line 21 def each(&block) @rankings.each do |team| if block_given? block.call team else yield team end end end
Private Instance Methods
add_poll_teams_to(collection, hash_colection)
click to toggle source
# File lib/sports_data_api/ncaafb/polls.rb, line 48 def add_poll_teams_to(collection, hash_colection) Array(hash_colection).each do |poll_team| collection << PollTeam.new(poll_team) end end