Class: Dribble::Players
Instance Attribute Summary collapse
-
#api_endpoint ⇒ Object
readonly
Returns the value of attribute api_endpoint.
-
#page ⇒ Object
readonly
Returns the value of attribute page.
-
#pages ⇒ Object
readonly
Returns the value of attribute pages.
-
#per_page ⇒ Object
readonly
Returns the value of attribute per_page.
-
#player_name ⇒ Object
readonly
Returns the value of attribute player_name.
-
#players ⇒ Object
readonly
Returns the value of attribute players.
-
#total ⇒ Object
readonly
Returns the value of attribute total.
Instance Method Summary collapse
-
#initialize(players, attributes = {}) ⇒ Players
constructor
A new instance of Players.
-
#next_page ⇒ Object
Next Page.
-
#paginate(options) ⇒ Object
Paginate.
-
#prev_page ⇒ Object
Previous Page.
Constructor Details
#initialize(players, attributes = {}) ⇒ Players
Returns a new instance of Players.
5 6 7 8 9 10 11 12 13 |
# File 'lib/dribble/players.rb', line 5 def initialize(players, attributes={}) @players = players @page = attributes[:page] @pages = attributes[:pages] @per_page = attributes[:per_page] @total = attributes[:total] @player_name = attributes[:player_name] @api_endpoint = self.class.to_s.split('::').last.downcase.to_sym end |
Instance Attribute Details
#api_endpoint ⇒ Object (readonly)
Returns the value of attribute api_endpoint.
3 4 5 |
# File 'lib/dribble/players.rb', line 3 def api_endpoint @api_endpoint end |
#page ⇒ Object (readonly)
Returns the value of attribute page.
3 4 5 |
# File 'lib/dribble/players.rb', line 3 def page @page end |
#pages ⇒ Object (readonly)
Returns the value of attribute pages.
3 4 5 |
# File 'lib/dribble/players.rb', line 3 def pages @pages end |
#per_page ⇒ Object (readonly)
Returns the value of attribute per_page.
3 4 5 |
# File 'lib/dribble/players.rb', line 3 def per_page @per_page end |
#player_name ⇒ Object (readonly)
Returns the value of attribute player_name.
3 4 5 |
# File 'lib/dribble/players.rb', line 3 def player_name @player_name end |
#players ⇒ Object (readonly)
Returns the value of attribute players.
3 4 5 |
# File 'lib/dribble/players.rb', line 3 def players @players end |
#total ⇒ Object (readonly)
Returns the value of attribute total.
3 4 5 |
# File 'lib/dribble/players.rb', line 3 def total @total end |
Instance Method Details
#next_page ⇒ Object
Next Page
35 36 37 38 39 |
# File 'lib/dribble/players.rb', line 35 def next_page = {:page => self.page.to_i + 1} raise Dribble::NoMorePagesAvailable.new('You are already on the last page.') if [:page] > self.pages.to_i send_request() end |
#paginate(options) ⇒ Object
Paginate
49 50 51 52 |
# File 'lib/dribble/players.rb', line 49 def paginate() raise Dribble::NoMorePagesAvailable.new('You are already on the last page.') if [:page] > self.pages.to_i send_request() end |
#prev_page ⇒ Object
Previous Page
22 23 24 25 26 |
# File 'lib/dribble/players.rb', line 22 def prev_page = {:page => self.page.to_i - 1} raise Dribble::NoMorePagesAvailable.new('You are already on the first page.') if [:page] <= 0 send_request() end |