Class: SportsDataApi::Ncaafb::Polls
- Inherits:
-
Object
- Object
- SportsDataApi::Ncaafb::Polls
- Includes:
- Enumerable
- Defined in:
- lib/sports_data_api/ncaafb/polls.rb
Instance Attribute Summary collapse
-
#candidates ⇒ Object
readonly
Returns the value of attribute candidates.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#rankings ⇒ Object
readonly
Returns the value of attribute rankings.
-
#season ⇒ Object
readonly
Returns the value of attribute season.
-
#season_type ⇒ Object
readonly
Returns the value of attribute season_type.
-
#week ⇒ Object
readonly
Returns the value of attribute week.
Class Method Summary collapse
-
.valid_name?(poll) ⇒ Boolean
Check if the requested poll is a valid Ncaafb poll type.
-
.valid_week?(week) ⇒ Boolean
The only valid week nr is 1..21.
Instance Method Summary collapse
-
#each(&block) ⇒ Object
Make the class Enumerable.
-
#initialize(polls_hash) ⇒ Polls
constructor
A new instance of Polls.
Constructor Details
#initialize(polls_hash) ⇒ Polls
Returns a new instance of Polls.
7 8 9 10 11 12 13 14 15 16 17 |
# 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 |
Instance Attribute Details
#candidates ⇒ Object (readonly)
Returns the value of attribute candidates.
6 7 8 |
# File 'lib/sports_data_api/ncaafb/polls.rb', line 6 def candidates @candidates end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
6 7 8 |
# File 'lib/sports_data_api/ncaafb/polls.rb', line 6 def id @id end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
6 7 8 |
# File 'lib/sports_data_api/ncaafb/polls.rb', line 6 def name @name end |
#rankings ⇒ Object (readonly)
Returns the value of attribute rankings.
6 7 8 |
# File 'lib/sports_data_api/ncaafb/polls.rb', line 6 def rankings @rankings end |
#season ⇒ Object (readonly)
Returns the value of attribute season.
6 7 8 |
# File 'lib/sports_data_api/ncaafb/polls.rb', line 6 def season @season end |
#season_type ⇒ Object (readonly)
Returns the value of attribute season_type.
6 7 8 |
# File 'lib/sports_data_api/ncaafb/polls.rb', line 6 def season_type @season_type end |
#week ⇒ Object (readonly)
Returns the value of attribute week.
6 7 8 |
# File 'lib/sports_data_api/ncaafb/polls.rb', line 6 def week @week end |
Class Method Details
.valid_name?(poll) ⇒ Boolean
Check if the requested poll is a valid Ncaafb poll type.
The only valid polls are: :AP25, :EU25, :CFP25, :FCSC25, :H25, :FCS25
37 38 39 |
# 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) ⇒ Boolean
The only valid week nr is 1..21
42 43 44 |
# File 'lib/sports_data_api/ncaafb/polls.rb', line 42 def valid_week?(week) (1..21).include?(week.to_i) end |
Instance Method Details
#each(&block) ⇒ Object
Make the class Enumerable
21 22 23 24 25 26 27 28 29 |
# 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 |