Class: GolfSwitch::AvailableCourse
- Defined in:
- lib/golf_switch/available_course.rb
Instance Attribute Summary collapse
-
#addr1 ⇒ Object
Returns the value of attribute addr1.
-
#cc_allow ⇒ Object
Returns the value of attribute cc_allow.
-
#curr ⇒ Object
Returns the value of attribute curr.
-
#dates ⇒ Object
Returns the value of attribute dates.
-
#f_prc ⇒ Object
Returns the value of attribute f_prc.
-
#is_gsw ⇒ Object
Returns the value of attribute is_gsw.
-
#max_rew_pts ⇒ Object
Returns the value of attribute max_rew_pts.
-
#msg ⇒ Object
Returns the value of attribute msg.
-
#note ⇒ Object
Returns the value of attribute note.
-
#rating_cnt ⇒ Object
Returns the value of attribute rating_cnt.
-
#rc ⇒ Object
Returns the value of attribute rc.
-
#rt_type ⇒ Object
Returns the value of attribute rt_type.
-
#t_prc ⇒ Object
Returns the value of attribute t_prc.
-
#zip ⇒ Object
Returns the value of attribute zip.
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
-
#initialize(attributes = {}) ⇒ AvailableCourse
constructor
ccAllow Comma separated list of allowed credit card types.VI: Visa,MC: Mastercard,AX: American Express,DS: Discover.
- #parse_date_info(value) ⇒ Object
Methods inherited from Course
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
#addr1 ⇒ Object
Returns the value of attribute addr1.
3 4 5 |
# File 'lib/golf_switch/available_course.rb', line 3 def addr1 @addr1 end |
#cc_allow ⇒ Object
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 |
#curr ⇒ Object
Returns the value of attribute curr.
3 4 5 |
# File 'lib/golf_switch/available_course.rb', line 3 def curr @curr end |
#dates ⇒ Object
Returns the value of attribute dates.
3 4 5 |
# File 'lib/golf_switch/available_course.rb', line 3 def dates @dates end |
#f_prc ⇒ Object
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_gsw ⇒ Object
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_pts ⇒ Object
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 |
#msg ⇒ Object
Returns the value of attribute msg.
3 4 5 |
# File 'lib/golf_switch/available_course.rb', line 3 def msg @msg end |
#note ⇒ Object
Returns the value of attribute note.
3 4 5 |
# File 'lib/golf_switch/available_course.rb', line 3 def note @note end |
#rating_cnt ⇒ Object
Returns the value of attribute rating_cnt.
3 4 5 |
# File 'lib/golf_switch/available_course.rb', line 3 def @rating_cnt end |
#rc ⇒ Object
Returns the value of attribute rc.
3 4 5 |
# File 'lib/golf_switch/available_course.rb', line 3 def rc @rc end |
#rt_type ⇒ Object
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_prc ⇒ Object
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 |
#zip ⇒ Object
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 |