class Mousecop::Player
Attributes
conference[RW]
id[RW]
image[RW]
name[RW]
Public Class Methods
all()
click to toggle source
# File lib/mousecop/player.rb, line 6 def self.all data = PlayerSource.new.fetch_data('/players') data.collect do |player| self.create(name: player["name"], id: player["id"], image: player["image"]) end end
create(attributes= {})
click to toggle source
# File lib/mousecop/player.rb, line 25 def self.create(attributes= {}) self.new.tap do |player| player.name = attributes[:name] player.id = attributes[:id] player.image = attributes[:image] end end
first()
click to toggle source
# File lib/mousecop/player.rb, line 20 def self.first @all ||= self.all @all.first end
sample()
click to toggle source
# File lib/mousecop/player.rb, line 15 def self.sample player = PlayerSource.new.fetch_data('/player').first self.create(name: player["name"], id: player["id"], image: player["image"]) end