Class: Infostrada::Competition

Inherits:
Object
  • Object
show all
Defined in:
lib/infostrada/competition.rb

Overview

n_CompetitionSet is an indicator for the type of Competition:

1 = domestic league 2 = domestic cup 3 = international club competition (e.g. Champions League) 4 = country competition (e.g. World Cup)

n_CompetitionLevel is an indicator for the level of a domestic competition:

1 = highest level (e.g. German Bundesliga) 2 = 2nd highest level (e.g. German 2. Bundesliga) 3 = 3rd highest level and so on

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(hash = {}, &block) ⇒ Competition

Returns a new instance of Competition.



25
26
27
28
29
30
31
32
# File 'lib/infostrada/competition.rb', line 25

def initialize(hash = {}, &block)
  @id     = hash.delete('n_CompetitionID')
  @name   = hash.delete('c_Competition')
  @nation = Nation.new(hash, 'competition') if hash.any?

  block.call(self) if block_given?
  self
end

Instance Attribute Details

#idObject

Returns the value of attribute id.



15
16
17
# File 'lib/infostrada/competition.rb', line 15

def id
  @id
end

#levelObject

Returns the value of attribute level.



15
16
17
# File 'lib/infostrada/competition.rb', line 15

def level
  @level
end

#nameObject

Returns the value of attribute name.



15
16
17
# File 'lib/infostrada/competition.rb', line 15

def name
  @name
end

#nationObject

Returns the value of attribute nation.



15
16
17
# File 'lib/infostrada/competition.rb', line 15

def nation
  @nation
end

#setObject

Returns the value of attribute set.



15
16
17
# File 'lib/infostrada/competition.rb', line 15

def set
  @set
end

Class Method Details

.from_json(json = {}) ⇒ Object



17
18
19
20
21
22
23
# File 'lib/infostrada/competition.rb', line 17

def self.from_json(json = {})
  new do |competition|
    competition.id     = json['id']
    competition.name   = json['name']
    competition.nation = Nation.from_json(json['nation'], 'competition') if json['nation']
  end
end