Class: GolfSwitch::Player

Inherits:
Object
  • Object
show all
Defined in:
lib/golf_switch/player.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attributes = {}) ⇒ Player

Returns a new instance of Player.



6
7
8
9
10
11
12
13
14
# File 'lib/golf_switch/player.rb', line 6

def initialize(attributes={})
  attributes.each do |name, value|
    begin
      send("#{name}=", value)
    rescue
      puts "invalid attribute #{name} in player"
    end
  end
end

Instance Attribute Details

#address1Object

Returns the value of attribute address1.



3
4
5
# File 'lib/golf_switch/player.rb', line 3

def address1
  @address1
end

#cityObject

Returns the value of attribute city.



3
4
5
# File 'lib/golf_switch/player.rb', line 3

def city
  @city
end

#countryObject

Returns the value of attribute country.



4
5
6
# File 'lib/golf_switch/player.rb', line 4

def country
  @country
end

#emailObject

Returns the value of attribute email.



3
4
5
# File 'lib/golf_switch/player.rb', line 3

def email
  @email
end

#first_nameObject

Returns the value of attribute first_name.



3
4
5
# File 'lib/golf_switch/player.rb', line 3

def first_name
  @first_name
end

#handicapObject

Returns the value of attribute handicap.



4
5
6
# File 'lib/golf_switch/player.rb', line 4

def handicap
  @handicap
end

#last_nameObject

Returns the value of attribute last_name.



3
4
5
# File 'lib/golf_switch/player.rb', line 3

def last_name
  @last_name
end

#member_noObject

Returns the value of attribute member_no.



4
5
6
# File 'lib/golf_switch/player.rb', line 4

def member_no
  @member_no
end

#phoneObject

Returns the value of attribute phone.



3
4
5
# File 'lib/golf_switch/player.rb', line 3

def phone
  @phone
end

#postal_codeObject

Returns the value of attribute postal_code.



4
5
6
# File 'lib/golf_switch/player.rb', line 4

def postal_code
  @postal_code
end

#profile_idObject

Returns the value of attribute profile_id.



3
4
5
# File 'lib/golf_switch/player.rb', line 3

def profile_id
  @profile_id
end

#rewards_idObject

Returns the value of attribute rewards_id.



4
5
6
# File 'lib/golf_switch/player.rb', line 4

def rewards_id
  @rewards_id
end

#rewards_pgm_idObject

Returns the value of attribute rewards_pgm_id.



4
5
6
# File 'lib/golf_switch/player.rb', line 4

def rewards_pgm_id
  @rewards_pgm_id
end

#stateObject

Returns the value of attribute state.



4
5
6
# File 'lib/golf_switch/player.rb', line 4

def state
  @state
end

Instance Method Details

#option_attributesObject



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/golf_switch/player.rb', line 16

def option_attributes
  options = {}
  options.merge!("ProfileId"=>@profile_id) unless @profile_id.blank?
  options.merge!("FirstName"=>@first_name)
  options.merge!("LastName"=>@last_name)
  options.merge!("Email"=>@email)
  options.merge!("Phone"=>@phone)
  options.merge!("Address1"=>@address1) unless @address1.blank?
  options.merge!("City"=>@city)
  options.merge!("State"=>@state)
  options.merge!("Country"=>@country || "USA")
  options.merge!("PostalCode"=>@postal_code)
  options.merge!("MemberNo"=>@member_no) unless @member_no.blank?
  options.merge!("Handicap"=>@handicap) unless @handicap.blank? && @handicap!="Handicap"
  options.merge!("RewardsPgmId"=>@rewards_pgm_id) unless @rewards_pgm_id.blank?
  options.merge!("RewardsId"=>@rewards_id) unless @rewards_id.blank?
  options
end