Class: GolfSwitch::GolfBook

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

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attributes = {}) ⇒ GolfBook

Returns a new instance of GolfBook.



9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/golf_switch/golf_book.rb', line 9

def initialize(attributes={})
  attributes.each do |name, value|
    begin
      if name.to_s=="cxl_policy"
        @cxl_policy = GolfSwitch::CoursePolicy.new(value)
      else
        send("#{name}=", value)
      end
    rescue
      puts "Add #{name} as accessor in Golf Book"
    end
  end
end

Instance Attribute Details

#booking_idObject

Returns the value of attribute booking_id.



5
6
7
# File 'lib/golf_switch/golf_book.rb', line 5

def booking_id
  @booking_id
end

#confirmation_noObject

Returns the value of attribute confirmation_no.



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

def confirmation_no
  @confirmation_no
end

#course_emailObject

Returns the value of attribute course_email.



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

def course_email
  @course_email
end

#course_idObject

Returns the value of attribute course_id.



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

def course_id
  @course_id
end

#course_nameObject

Returns the value of attribute course_name.



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

def course_name
  @course_name
end

#course_noteObject

Returns the value of attribute course_note.



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

def course_note
  @course_note
end

#course_phoneObject

Returns the value of attribute course_phone.



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

def course_phone
  @course_phone
end

#course_x_idObject

Returns the value of attribute course_x_id.



7
8
9
# File 'lib/golf_switch/golf_book.rb', line 7

def course_x_id
  @course_x_id
end

#course_xidObject

Returns the value of attribute course_xid.



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

def course_xid
  @course_xid
end

#curr_chargedObject

Returns the value of attribute curr_charged.



6
7
8
# File 'lib/golf_switch/golf_book.rb', line 6

def curr_charged
  @curr_charged
end

#curr_greens_feeObject

Returns the value of attribute curr_greens_fee.



5
6
7
# File 'lib/golf_switch/golf_book.rb', line 5

def curr_greens_fee
  @curr_greens_fee
end

#cxl_policyObject

Returns the value of attribute cxl_policy.



7
8
9
# File 'lib/golf_switch/golf_book.rb', line 7

def cxl_policy
  @cxl_policy
end

#imgObject

Returns the value of attribute img.



7
8
9
# File 'lib/golf_switch/golf_book.rb', line 7

def img
  @img
end

#msgObject

Returns the value of attribute msg.



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

def msg
  @msg
end

#num_playersObject

Returns the value of attribute num_players.



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

def num_players
  @num_players
end

#on_reqObject

Returns the value of attribute on_req.



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

def on_req
  @on_req
end

#play_dateObject

Returns the value of attribute play_date.



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

def play_date
  @play_date
end

#play_timeObject

Returns the value of attribute play_time.



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

def play_time
  @play_time
end

#rate_policyObject

Returns the value of attribute rate_policy.



7
8
9
# File 'lib/golf_switch/golf_book.rb', line 7

def rate_policy
  @rate_policy
end

#rcObject

Returns the value of attribute rc.



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

def rc
  @rc
end

#tot_cc_chargedObject

Returns the value of attribute tot_cc_charged.



5
6
7
# File 'lib/golf_switch/golf_book.rb', line 5

def tot_cc_charged
  @tot_cc_charged
end

#tot_golf_pass_roundsObject

Returns the value of attribute tot_golf_pass_rounds.



6
7
8
# File 'lib/golf_switch/golf_book.rb', line 6

def tot_golf_pass_rounds
  @tot_golf_pass_rounds
end

#tot_greens_feeObject

Returns the value of attribute tot_greens_fee.



5
6
7
# File 'lib/golf_switch/golf_book.rb', line 5

def tot_greens_fee
  @tot_greens_fee
end

#tot_non_refundableObject

Returns the value of attribute tot_non_refundable.



6
7
8
# File 'lib/golf_switch/golf_book.rb', line 6

def tot_non_refundable
  @tot_non_refundable
end

#tot_trans_feeObject

Returns the value of attribute tot_trans_fee.



5
6
7
# File 'lib/golf_switch/golf_book.rb', line 5

def tot_trans_fee
  @tot_trans_fee
end

#tot_voucher_chargedObject

Returns the value of attribute tot_voucher_charged.



6
7
8
# File 'lib/golf_switch/golf_book.rb', line 6

def tot_voucher_charged
  @tot_voucher_charged
end

Class Method Details

.parse_golf_books(response) ⇒ Object



23
24
25
26
27
28
29
30
31
32
33
# File 'lib/golf_switch/golf_book.rb', line 23

def self.parse_golf_books(response)
  golf_books = []
  if response[:golf_books] && response[:golf_books][:golf_book].is_a?(Array)
    response[:golf_books][:golf_book].each do |golf_book|
      golf_books << GolfSwitch::GolfBook.new(response[:golf_books][:golf_book])
    end
  elsif response[:golf_books] && response[:golf_books][:golf_book].is_a?(Hash)
    golf_books << GolfSwitch::GolfBook.new(response[:golf_books][:golf_book])
  end
  golf_books
end

Instance Method Details

#to_hashObject



35
36
37
38
39
# File 'lib/golf_switch/golf_book.rb', line 35

def to_hash
  hash = {}
  instance_variables.each {|var| hash[var.to_s.delete("@")] = instance_variable_get(var) }
  hash
end