class PlaylyfeClient::V2::Collection
Attributes
game[R]
Public Class Methods
new(game)
click to toggle source
shoudl be redefined in subclasses
# File lib/playlyfe_client/v2/collection.rb, line 49 def initialize(game) @game= game @items=[] fill_items([]) end
Public Instance Methods
add(item)
click to toggle source
# File lib/playlyfe_client/v2/collection.rb, line 10 def add(item) @items << item end
all()
click to toggle source
# File lib/playlyfe_client/v2/collection.rb, line 6 def all @items end
each(&block)
click to toggle source
# File lib/playlyfe_client/v2/collection.rb, line 14 def each &block @items.each &block end
find(str)
click to toggle source
# File lib/playlyfe_client/v2/collection.rb, line 18 def find(str) (@items.detect {|item| item.id.include?(str)}) end
find_all(str_arr)
click to toggle source
# File lib/playlyfe_client/v2/collection.rb, line 22 def find_all(str_arr) coll=[] str_arr.each do |str| coll << self.find(str) end coll.compact end
first()
click to toggle source
# File lib/playlyfe_client/v2/collection.rb, line 30 def first @items.first end
last()
click to toggle source
# File lib/playlyfe_client/v2/collection.rb, line 34 def last @items.last end
size()
click to toggle source
# File lib/playlyfe_client/v2/collection.rb, line 42 def size @items.size end
to_a()
click to toggle source
# File lib/playlyfe_client/v2/collection.rb, line 38 def to_a @items end
Private Instance Methods
fill_items(hash_array)
click to toggle source
# File lib/playlyfe_client/v2/collection.rb, line 55 def fill_items(hash_array) hash_array.each do |hash| @items << hash end end