class PGATourReader::PGA_Tournament
Attributes
attributes[RW]
course[RW]
cup_points[RW]
end_date[RW]
location[RW]
name[RW]
purse[RW]
season[RW]
start_date[RW]
url[RW]
winner[RW]
winnings[RW]
Public Class Methods
new(start_date, end_date, season, attributes = {})
click to toggle source
# File lib/PGA_tournament.rb, line 5 def initialize(start_date, end_date, season, attributes = {}) @start_date = start_date @end_date = end_date @season = season self.add_attributes(attributes) end
Public Instance Methods
add_attributes(attributes)
click to toggle source
accepts hash of many tournament attributes and assigns them to self
# File lib/PGA_tournament.rb, line 13 def add_attributes(attributes) @attributes = attributes attributes.each {|key, value| self.send("#{key}=", value)} end
get_attribute(attribute)
click to toggle source
gets a single attribute's value
# File lib/PGA_tournament.rb, line 24 def get_attribute(attribute) request = is_attribute?(attribute) if request puts "#{request} : #{@attributes[request]}" end end
is_attribute?(attribute)
click to toggle source
checks to see if attribute this tournament contains and returns attributes' symbol
# File lib/PGA_tournament.rb, line 32 def is_attribute?(attribute) @attributes.keys.detect{|key| key.to_s == attribute} end
list_attributes()
click to toggle source
lists all attributes self has
# File lib/PGA_tournament.rb, line 37 def list_attributes puts "" @attributes.keys[0..-2].each{|a| print "#{a}, "} puts attributes.keys.last end
print_attributes()
click to toggle source
prints all attributes self has
# File lib/PGA_tournament.rb, line 19 def print_attributes @attributes.each{|attribute, value| puts "#{attribute}: #{value}"} end
print_date_name()
click to toggle source
prints basic information about self in “2/2 - 2/6: Greenbriar Classic” format
# File lib/PGA_tournament.rb, line 44 def print_date_name() puts "#{self.start_date} - #{self.end_date}: #{self.name}" end