Class: Infostrada::Team
- Inherits:
-
Object
- Object
- Infostrada::Team
- Extended by:
- Forwardable
- Defined in:
- lib/infostrada/team.rb
Instance Attribute Summary collapse
-
#details ⇒ Object
Returns the value of attribute details.
-
#edition_id ⇒ Object
Returns the value of attribute edition_id.
-
#id ⇒ Object
Returns the value of attribute id.
-
#name ⇒ Object
Returns the value of attribute name.
-
#nation ⇒ Object
Returns the value of attribute nation.
-
#short_name ⇒ Object
Returns the value of attribute short_name.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(hash = {}, prefix, &block) ⇒ Team
constructor
A new instance of Team.
- #team_id=(id) ⇒ Object
- #team_name=(name) ⇒ Object
- #team_short=(short_name) ⇒ Object
Constructor Details
#initialize(hash = {}, prefix, &block) ⇒ Team
Returns a new instance of Team.
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/infostrada/team.rb', line 26 def initialize(hash = {}, prefix, &block) @edition_id = hash['edition_id'] hash.each do |key, value| case key.info_snake_case when /^[cn]\w+#{prefix}_?team_id$/ self.send('team_id=', value) when /^[cn]\w+#{prefix}_?team$/ self.send('team_name=', value) when /^[cn]\w+#{prefix}_?team_short$/ self.send('team_short=', value) end end @nation = Nation.new(hash, "#{prefix}_team") block.call(self) if block_given? self end |
Instance Attribute Details
#details ⇒ Object
Returns the value of attribute details.
9 10 11 |
# File 'lib/infostrada/team.rb', line 9 def details @details end |
#edition_id ⇒ Object
Returns the value of attribute edition_id.
9 10 11 |
# File 'lib/infostrada/team.rb', line 9 def edition_id @edition_id end |
#id ⇒ Object
Returns the value of attribute id.
9 10 11 |
# File 'lib/infostrada/team.rb', line 9 def id @id end |
#name ⇒ Object
Returns the value of attribute name.
9 10 11 |
# File 'lib/infostrada/team.rb', line 9 def name @name end |
#nation ⇒ Object
Returns the value of attribute nation.
9 10 11 |
# File 'lib/infostrada/team.rb', line 9 def nation @nation end |
#short_name ⇒ Object
Returns the value of attribute short_name.
9 10 11 |
# File 'lib/infostrada/team.rb', line 9 def short_name @short_name end |
Class Method Details
.from_json(json = {}, prefix) ⇒ Object
16 17 18 19 20 21 22 23 24 |
# File 'lib/infostrada/team.rb', line 16 def self.from_json(json = {}, prefix) new(prefix) do |team| team.id = json['id'] team.name = json['name'] team.short_name = json['short_name'] team.nation = Nation.from_json(json['nation'], "#{prefix}_team") if json['nation'] team.edition_id = json['edition_id'] end end |
.where(options = {}) ⇒ Object
11 12 13 14 |
# File 'lib/infostrada/team.rb', line 11 def self.where( = {}) edition_id = .delete(:edition_id) TeamRequest.get_edition(edition_id.to_i) end |
Instance Method Details
#team_id=(id) ⇒ Object
45 46 47 |
# File 'lib/infostrada/team.rb', line 45 def team_id=(id) @id = id end |
#team_name=(name) ⇒ Object
49 50 51 |
# File 'lib/infostrada/team.rb', line 49 def team_name=(name) @name = name end |
#team_short=(short_name) ⇒ Object
53 54 55 |
# File 'lib/infostrada/team.rb', line 53 def team_short=(short_name) @short_name = short_name end |