Class: GolfSwitch::AvailableCourse

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

Instance Attribute Summary collapse

Attributes inherited from Course

#adv_days, #cou, #cty, #dist, #id, #img, #img_base, #inside_days, #lat, #lon, #nm, #on_req, #promo, #rating, #s_ar, #s_cou, #s_reg, #st, #xid

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Course

#img_url

Constructor Details

#initialize(attributes = {}) ⇒ AvailableCourse

ccAllow Comma separated list of allowed credit card types.VI: Visa,MC: Mastercard,AX: American Express,DS: Discover



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/golf_switch/available_course.rb', line 5

def initialize(attributes={})
  @dates = []

  attributes.each do |name, value|
    if name.to_s=="dates"

      parse_date_info(value)
    else
      begin
        send("#{name}=", value)
      rescue
        puts "#{name} attribute is not present"
      end
    end
  end
end

Instance Attribute Details

#addr1Object

Returns the value of attribute addr1.



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

def addr1
  @addr1
end

#cc_allowObject

Returns the value of attribute cc_allow.



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

def cc_allow
  @cc_allow
end

#currObject

Returns the value of attribute curr.



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

def curr
  @curr
end

#datesObject

Returns the value of attribute dates.



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

def dates
  @dates
end

#f_prcObject

Returns the value of attribute f_prc.



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

def f_prc
  @f_prc
end

#is_gswObject

Returns the value of attribute is_gsw.



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

def is_gsw
  @is_gsw
end

#max_rew_ptsObject

Returns the value of attribute max_rew_pts.



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

def max_rew_pts
  @max_rew_pts
end

#msgObject

Returns the value of attribute msg.



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

def msg
  @msg
end

#noteObject

Returns the value of attribute note.



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

def note
  @note
end

#rating_cntObject

Returns the value of attribute rating_cnt.



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

def rating_cnt
  @rating_cnt
end

#rcObject

Returns the value of attribute rc.



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

def rc
  @rc
end

#rt_typeObject

Returns the value of attribute rt_type.



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

def rt_type
  @rt_type
end

#t_prcObject

Returns the value of attribute t_prc.



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

def t_prc
  @t_prc
end

#zipObject

Returns the value of attribute zip.



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

def zip
  @zip
end

Class Method Details

.parse_courses(response_hash) ⇒ Object



21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/golf_switch/available_course.rb', line 21

def self.parse_courses(response_hash)
  courses= []

  if response_hash[:courses]
    avail_courses= response_hash[:courses][:al_course] || response_hash[:courses][:ca_course]
    if avail_courses.is_a?(Array)
      avail_courses.each do |course|
        begin
          courses  << AvailableCourse.new(course.merge(:img_base=>response_hash[:img_base]))
        end
      end
    elsif avail_courses.is_a?(Hash)
      courses  << AvailableCourse.new(avail_courses.merge(:img_base=>response_hash[:img_base]))
    end
  end
  courses
end

Instance Method Details

#parse_date_info(value) ⇒ Object



39
40
41
42
43
44
45
46
47
48
# File 'lib/golf_switch/available_course.rb', line 39

def parse_date_info(value)

  if value[:al_date].is_a?(Array)
    value[:al_date].each do |al_date|
      @dates << CourseAvailDate.parse_date_info(al_date)
    end
  elsif value[:al_date].is_a?(Hash)
     @dates << CourseAvailDate.parse_date_info(value[:al_date])
  end
end