Class: Fountain::Slots

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Defined in:
lib/fountain/slots.rb

Overview

Fountain Slot collection

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(data) ⇒ Slots

Returns a new instance of Slots.

Parameters:

  • data (Hash)

    Raw slot data



24
25
26
27
28
29
30
31
32
# File 'lib/fountain/slots.rb', line 24

def initialize(data)
  raw_data = Util.stringify_hash_keys data
  pagination = raw_data['pagination']
  if pagination.is_a? Hash
    @current_page = pagination['current']
    @last_page = pagination['last']
  end
  @slots = raw_data['slots'].map { |attr| Slot.new attr }
end

Instance Attribute Details

#current_pageObject (readonly)

Collection current page



11
12
13
# File 'lib/fountain/slots.rb', line 11

def current_page
  @current_page
end

#last_pageObject (readonly)

Collection last page



14
15
16
# File 'lib/fountain/slots.rb', line 14

def last_page
  @last_page
end

#slotsObject (readonly)

Slot collection



17
18
19
# File 'lib/fountain/slots.rb', line 17

def slots
  @slots
end

Instance Method Details

#inspectObject



34
35
36
37
38
39
40
41
# File 'lib/fountain/slots.rb', line 34

def inspect
  format(
    '#<%<class_name>s:0x%<object_id>p @count="%<count>s">',
    class_name: self.class.name,
    object_id: object_id,
    count: count
  )
end