Class: Dribble::Shots
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.
-
#shots ⇒ Object
readonly
Returns the value of attribute shots.
-
#total ⇒ Object
readonly
Returns the value of attribute total.
Instance Method Summary collapse
-
#initialize(shots, attributes = {}) ⇒ Shots
constructor
A new instance of Shots.
-
#next_page ⇒ Object
Next Page.
-
#paginate(options) ⇒ Object
Paginate.
-
#prev_page ⇒ Object
Previous Page.
Constructor Details
#initialize(shots, attributes = {}) ⇒ Shots
Returns a new instance of Shots.
5 6 7 8 9 10 11 12 13 |
# File 'lib/dribble/shots.rb', line 5 def initialize(shots, attributes={}) @shots = shots @page = attributes[:page] @pages = attributes[:pages] @per_page = attributes[:per_page] @total = attributes[:total] @player_name = attributes[:player_name] || nil @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/shots.rb', line 3 def api_endpoint @api_endpoint end |
#page ⇒ Object (readonly)
Returns the value of attribute page.
3 4 5 |
# File 'lib/dribble/shots.rb', line 3 def page @page end |
#pages ⇒ Object (readonly)
Returns the value of attribute pages.
3 4 5 |
# File 'lib/dribble/shots.rb', line 3 def pages @pages end |
#per_page ⇒ Object (readonly)
Returns the value of attribute per_page.
3 4 5 |
# File 'lib/dribble/shots.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/shots.rb', line 3 def player_name @player_name end |
#shots ⇒ Object (readonly)
Returns the value of attribute shots.
3 4 5 |
# File 'lib/dribble/shots.rb', line 3 def shots @shots end |
#total ⇒ Object (readonly)
Returns the value of attribute total.
3 4 5 |
# File 'lib/dribble/shots.rb', line 3 def total @total end |
Instance Method Details
#next_page ⇒ Object
Next Page
35 36 37 38 39 |
# File 'lib/dribble/shots.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/shots.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/shots.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 |