Class: Mousecop::Player
- Inherits:
-
Object
- Object
- Mousecop::Player
- Defined in:
- lib/mousecop/player.rb
Instance Attribute Summary collapse
-
#conference ⇒ Object
Returns the value of attribute conference.
-
#id ⇒ Object
Returns the value of attribute id.
-
#image ⇒ Object
Returns the value of attribute image.
-
#name ⇒ Object
Returns the value of attribute name.
Class Method Summary collapse
Instance Attribute Details
#conference ⇒ Object
Returns the value of attribute conference.
4 5 6 |
# File 'lib/mousecop/player.rb', line 4 def conference @conference end |
#id ⇒ Object
Returns the value of attribute id.
4 5 6 |
# File 'lib/mousecop/player.rb', line 4 def id @id end |
#image ⇒ Object
Returns the value of attribute image.
4 5 6 |
# File 'lib/mousecop/player.rb', line 4 def image @image end |
#name ⇒ Object
Returns the value of attribute name.
4 5 6 |
# File 'lib/mousecop/player.rb', line 4 def name @name end |
Class Method Details
.all ⇒ Object
6 7 8 9 10 11 12 13 |
# 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 = {}) ⇒ Object
25 26 27 28 29 30 31 |
# 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 ⇒ Object
20 21 22 23 |
# File 'lib/mousecop/player.rb', line 20 def self.first @all ||= self.all @all.first end |
.sample ⇒ Object
15 16 17 18 |
# 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 |