Class: Match

Inherits:
Object
  • Object
show all
Defined in:
lib/shooting_match_finder/match.rb

Constant Summary collapse

@@all =
[]

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(match_hash) ⇒ Match

takes in a hash to assign each match a name and a url for later use in #add_attributes.



7
8
9
10
# File 'lib/shooting_match_finder/match.rb', line 7

def initialize(match_hash) #takes in a hash to assign each match a name and a url for later use in #add_attributes.
  match_hash.each {|key, value| self.send(("#{key}="), value)}
  @@all << self
end

Instance Attribute Details

#descriptionObject

Returns the value of attribute description.



2
3
4
# File 'lib/shooting_match_finder/match.rb', line 2

def description
  @description
end

#entry_feeObject

Returns the value of attribute entry_fee.



2
3
4
# File 'lib/shooting_match_finder/match.rb', line 2

def entry_fee
  @entry_fee
end

#locationObject

Returns the value of attribute location.



2
3
4
# File 'lib/shooting_match_finder/match.rb', line 2

def location
  @location
end

#match_startObject

Returns the value of attribute match_start.



2
3
4
# File 'lib/shooting_match_finder/match.rb', line 2

def match_start
  @match_start
end

#match_urlObject

Returns the value of attribute match_url.



2
3
4
# File 'lib/shooting_match_finder/match.rb', line 2

def match_url
  @match_url
end

#nameObject

Returns the value of attribute name.



2
3
4
# File 'lib/shooting_match_finder/match.rb', line 2

def name
  @name
end

Class Method Details

.new_from_practiscore(match_array) ⇒ Object

Uses the hash array passed in by cli.rb to create matches.



12
13
14
# File 'lib/shooting_match_finder/match.rb', line 12

def self.new_from_practiscore(match_array) #Uses the hash array passed in by cli.rb to create matches.
  match_array.each{|match_hash| Match.new(match_hash)}
end

.show_matchesObject



20
21
22
# File 'lib/shooting_match_finder/match.rb', line 20

def self.show_matches
  @@all
end

Instance Method Details

#add_attributes(match_info) ⇒ Object

takes in a hash and uses mass assignment to add match details.



16
17
18
# File 'lib/shooting_match_finder/match.rb', line 16

def add_attributes(match_info) #takes in a hash and uses mass assignment to add match details.
  match_info.each {|key, value| self.send(("#{key}="), value)}
end