Class: Infostrada::Mock

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

Class Method Summary collapse

Class Method Details

.competition(type = :default) ⇒ Object



20
21
22
23
# File 'lib/infostrada/mock.rb', line 20

def competition(type = :default)
  json = JSONHelper::Competition.get(type)
  Infostrada::Competition.new(json)
end

.edition(type = :default) ⇒ Object



25
26
27
28
# File 'lib/infostrada/mock.rb', line 25

def edition(type = :default)
  json = JSONHelper::Edition.get(type)
  Infostrada::Edition.new(json)
end

.explainObject



7
8
9
10
11
12
13
14
15
16
17
18
# File 'lib/infostrada/mock.rb', line 7

def explain
  meths = %w(competition edition match_event match nation person_info
    phase player referee team_info team)
  puts 'Returns mock class instance for tests.'
  puts 'Available methods:'
  meths.each do |m|
    puts "\t - Infostrada::Mock.#{m}"
  end
  puts 'All the methods accept one or more arguments.'
  puts 'The first argument is *type*, which allows the selection of the mock json.'
  puts ''
end

.match(type = :cup_knock_out_finished_complete) ⇒ Object



35
36
37
38
# File 'lib/infostrada/mock.rb', line 35

def match(type = :cup_knock_out_finished_complete)
  json = JSONHelper::Match.get(type)
  Infostrada::Match.new(json)
end

.match_event(type = :event_1, match_id = nil) ⇒ Object



30
31
32
33
# File 'lib/infostrada/mock.rb', line 30

def match_event(type = :event_1, match_id = nil)
  json = JSONHelper::MatchEvent.get(type)
  Infostrada::MatchEvent.new(match_id, json)
end

.nation(type = :team) ⇒ Object



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

def nation(type = :team)
  json = JSONHelper::Nation.get(type)
  Infostrada::Nation.new(json, type.to_s)
end

.person_info(person_id = 611_005, type = :default) ⇒ Object



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

def person_info(person_id = 611_005, type = :default)
  json = JSONHelper::PersonInfo.get(type)
  Infostrada::PersonInfo.new(person_id, json)
end

.phase(type = :default) ⇒ Object



50
51
52
53
# File 'lib/infostrada/mock.rb', line 50

def phase(type = :default)
  json = JSONHelper::Phase.get(type).first
  Infostrada::Phase.new(json)
end

.player(type = :default) ⇒ Object



55
56
57
58
# File 'lib/infostrada/mock.rb', line 55

def player(type = :default)
  json = JSONHelper::Player.get(type)
  Infostrada::Player.new(json)
end

.referee(type = :complete_referee_match) ⇒ Object



60
61
62
63
# File 'lib/infostrada/mock.rb', line 60

def referee(type = :complete_referee_match)
  json = JSONHelper::Referee.get(type)
  Infostrada::Referee.new(json)
end

.team(type = :default) ⇒ Object



70
71
72
73
# File 'lib/infostrada/mock.rb', line 70

def team(type = :default)
  json = JSONHelper::Team.get(type)
  Infostrada::Team.new(json, '')
end

.team_info(type = :default) ⇒ Object



65
66
67
68
# File 'lib/infostrada/mock.rb', line 65

def team_info(type = :default)
  json = JSONHelper::TeamInfo.get(type)
  Infostrada::TeamInfo.new(json)
end