Class: FootballApi::Card

Inherits:
Object
  • Object
show all
Defined in:
lib/football_api/card.rb

Constant Summary collapse

TYPE =
[ :yellow, :red ]

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(hash = {}) ⇒ Card

Returns a new instance of Card.



7
8
9
10
11
12
13
# File 'lib/football_api/card.rb', line 7

def initialize(hash = {})
  return {} unless TYPE.include?(hash[:type])

  @type = hash[:type]
  @minute = hash[:minute]
  @player = parse_player(hash)
end

Instance Attribute Details

#minuteObject

Returns the value of attribute minute.



5
6
7
# File 'lib/football_api/card.rb', line 5

def minute
  @minute
end

#playerObject

Returns the value of attribute player.



5
6
7
# File 'lib/football_api/card.rb', line 5

def player
  @player
end

#typeObject

Returns the value of attribute type.



5
6
7
# File 'lib/football_api/card.rb', line 5

def type
  @type
end

Instance Method Details

#parse_player(hash = {}) ⇒ Object



15
16
17
# File 'lib/football_api/card.rb', line 15

def parse_player(hash = {})
  FootballApi::Player.new(hash)
end