Class: Infostrada::Team

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Defined in:
lib/infostrada/team.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(hash, prefix) ⇒ Team

Returns a new instance of Team.



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/infostrada/team.rb', line 16

def initialize(hash, prefix)
  @edition_id = hash['edition_id']

  hash.each do |key, value|
    case key.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")
end

Instance Attribute Details

#edition_idObject

Returns the value of attribute edition_id.



9
10
11
# File 'lib/infostrada/team.rb', line 9

def edition_id
  @edition_id
end

#idObject

Returns the value of attribute id.



9
10
11
# File 'lib/infostrada/team.rb', line 9

def id
  @id
end

#nameObject

Returns the value of attribute name.



9
10
11
# File 'lib/infostrada/team.rb', line 9

def name
  @name
end

#nationObject

Returns the value of attribute nation.



9
10
11
# File 'lib/infostrada/team.rb', line 9

def nation
  @nation
end

#short_nameObject

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

.where(options = {}) ⇒ Object



11
12
13
14
# File 'lib/infostrada/team.rb', line 11

def self.where(options = {})
  edition_id = options.delete(:edition_id)
  teams = TeamRequest.get_edition(edition_id.to_i)
end

Instance Method Details

#detailsObject



45
46
47
# File 'lib/infostrada/team.rb', line 45

def details
  info ||= TeamInfo.fetch(self)
end

#team_id=(id) ⇒ Object



33
34
35
# File 'lib/infostrada/team.rb', line 33

def team_id=(id)
  @id = id
end

#team_name=(name) ⇒ Object



37
38
39
# File 'lib/infostrada/team.rb', line 37

def team_name=(name)
  @name = name
end

#team_short=(short_name) ⇒ Object



41
42
43
# File 'lib/infostrada/team.rb', line 41

def team_short=(short_name)
  @short_name = short_name
end