Class: Dribble::Shots

Inherits:
Object show all
Defined in:
lib/dribble/shots.rb

Direct Known Subclasses

Debuts, Everyones, Following, Popular

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(shots, attributes = {}) ⇒ Shots

Returns a new instance of Shots.



5
6
7
8
9
10
11
# 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]
end

Instance Attribute Details

#pageObject (readonly)

Returns the value of attribute page.



3
4
5
# File 'lib/dribble/shots.rb', line 3

def page
  @page
end

#pagesObject (readonly)

Returns the value of attribute pages.



3
4
5
# File 'lib/dribble/shots.rb', line 3

def pages
  @pages
end

#per_pageObject (readonly)

Returns the value of attribute per_page.



3
4
5
# File 'lib/dribble/shots.rb', line 3

def per_page
  @per_page
end

#shotsObject (readonly)

Returns the value of attribute shots.



3
4
5
# File 'lib/dribble/shots.rb', line 3

def shots
  @shots
end

#totalObject (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_pageObject



14
15
16
17
18
19
# File 'lib/dribble/shots.rb', line 14

def next_page
  api_endpoint  = self.class.to_s.split('::').last.downcase.to_sym
  options       = {:page => self.page.to_i + 1}
  raise Dribble::NoMorePagesAvailable.new('You are already on the last page.') if options[:page] > self.pages.to_i
  Dribble::Shot.send(api_endpoint, options)
end