Class: Infostrada::Edition

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

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

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

Returns a new instance of Edition.



27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/infostrada/edition.rb', line 27

def initialize(hash = {}, &block)
  @id = hash.delete('n_EditionID')
  @season = hash.delete('c_Season')

  if hash['d_EditionStartDate']
    @start_date = Formatter.format_date(hash.delete('d_EditionStartDate'))
  end

  @end_date = Formatter.format_date(hash.delete('d_EditionEndDate')) if hash['d_EditionEndDate']

  @competition = Competition.new(hash)

  block.call(self) if block_given?
  self
end

Instance Attribute Details

#competitionObject

Returns the value of attribute competition.



7
8
9
# File 'lib/infostrada/edition.rb', line 7

def competition
  @competition
end

#end_dateObject

Returns the value of attribute end_date.



7
8
9
# File 'lib/infostrada/edition.rb', line 7

def end_date
  @end_date
end

#idObject

Returns the value of attribute id.



7
8
9
# File 'lib/infostrada/edition.rb', line 7

def id
  @id
end

#seasonObject

Returns the value of attribute season.



7
8
9
# File 'lib/infostrada/edition.rb', line 7

def season
  @season
end

#start_dateObject

Returns the value of attribute start_date.



7
8
9
# File 'lib/infostrada/edition.rb', line 7

def start_date
  @start_date
end

Class Method Details

.allObject



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

def self.all
  editions = EditionRequest.get_list
end

.from_json(json = {}) ⇒ Object



16
17
18
19
20
21
22
23
24
25
# File 'lib/infostrada/edition.rb', line 16

def self.from_json(json = {})
  self.new do |edition|
    edition.id          = json['id']
    edition.competition = json['competition']
    edition.season      = json['season']
    edition.start_date  = json['start_date']
    edition.end_date    = json['end_date']
    edition.competition = Competition.from_json(json['competition'])
  end
end

Instance Method Details

#phasesObject

Get phases for this edition



48
49
50
# File 'lib/infostrada/edition.rb', line 48

def phases
  Phase.where(edition_id: id)
end

#teamsObject



43
44
45
# File 'lib/infostrada/edition.rb', line 43

def teams
  Team.all(id)
end