Class: GolfSwitch::CourseInfoCourse
- Defined in:
- lib/golf_switch/course_info_course.rb
Instance Attribute Summary collapse
-
#addr1 ⇒ Object
Returns the value of attribute addr1.
-
#allow_players ⇒ Object
Returns the value of attribute allow_players.
-
#cc_allow ⇒ Object
Returns the value of attribute cc_allow.
-
#curr ⇒ Object
Returns the value of attribute curr.
-
#cxl_policy ⇒ Object
Returns the value of attribute cxl_policy.
-
#designer ⇒ Object
Returns the value of attribute designer.
-
#dress_code ⇒ Object
Returns the value of attribute dress_code.
-
#from_price ⇒ Object
Returns the value of attribute from_price.
-
#greens ⇒ Object
Returns the value of attribute greens.
-
#handicaps ⇒ Object
Returns the value of attribute handicaps.
-
#has_net_rates ⇒ Object
Returns the value of attribute has_net_rates.
-
#has_trade ⇒ Object
Returns the value of attribute has_trade.
-
#holes ⇒ Object
Returns the value of attribute holes.
-
#imgs ⇒ Object
Returns the value of attribute imgs.
-
#max_reward_points ⇒ Object
Returns the value of attribute max_reward_points.
-
#note ⇒ Object
Returns the value of attribute note.
-
#pars ⇒ Object
Returns the value of attribute pars.
-
#payment_terms ⇒ Object
Returns the value of attribute payment_terms.
-
#rating_cnt ⇒ Object
Returns the value of attribute rating_cnt.
-
#score_card ⇒ Object
Returns the value of attribute score_card.
-
#services ⇒ Object
Returns the value of attribute services.
-
#short_promo ⇒ Object
Returns the value of attribute short_promo.
-
#to_price ⇒ Object
Returns the value of attribute to_price.
-
#yard_ages ⇒ Object
Returns the value of attribute yard_ages.
-
#year_built ⇒ Object
Returns the value of attribute year_built.
-
#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
- #images(protocol = "https") ⇒ Object
-
#initialize(attributes = {}) ⇒ CourseInfoCourse
constructor
A new instance of CourseInfoCourse.
- #no_of_allowed_player ⇒ Object
- #parse_images(imgs) ⇒ Object
- #parse_score_card(scores) ⇒ Object
- #set_course_image ⇒ Object
Methods inherited from Course
Constructor Details
#initialize(attributes = {}) ⇒ CourseInfoCourse
Returns a new instance of CourseInfoCourse.
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/golf_switch/course_info_course.rb', line 8 def initialize(attributes={}) @yard_ages= [] @pars = [] @handicaps = [] @imgs = [] attributes.each do |name, value| begin if name.to_s=="imgs" parse_images(value) elsif name.to_s =="cxl_policy" @cxl_policy = GolfSwitch::CoursePolicy.new(value) elsif name.to_s == "score_card" @yard_ages = parse_score_card((value[:yardages][:yardage] rescue nil)) @pars = parse_score_card((value[:pars][:par] rescue nil)) @handicaps =parse_score_card((value[:handicaps][:handicap] rescue nil)) else send("#{name}=", value) end rescue puts "Add #{name} as accessor in Corse Info Course" end end set_course_image end |
Instance Attribute Details
#addr1 ⇒ Object
Returns the value of attribute addr1.
3 4 5 |
# File 'lib/golf_switch/course_info_course.rb', line 3 def addr1 @addr1 end |
#allow_players ⇒ Object
Returns the value of attribute allow_players.
4 5 6 |
# File 'lib/golf_switch/course_info_course.rb', line 4 def allow_players @allow_players end |
#cc_allow ⇒ Object
Returns the value of attribute cc_allow.
4 5 6 |
# File 'lib/golf_switch/course_info_course.rb', line 4 def cc_allow @cc_allow end |
#curr ⇒ Object
Returns the value of attribute curr.
3 4 5 |
# File 'lib/golf_switch/course_info_course.rb', line 3 def curr @curr end |
#cxl_policy ⇒ Object
Returns the value of attribute cxl_policy.
5 6 7 |
# File 'lib/golf_switch/course_info_course.rb', line 5 def cxl_policy @cxl_policy end |
#designer ⇒ Object
Returns the value of attribute designer.
4 5 6 |
# File 'lib/golf_switch/course_info_course.rb', line 4 def designer @designer end |
#dress_code ⇒ Object
Returns the value of attribute dress_code.
5 6 7 |
# File 'lib/golf_switch/course_info_course.rb', line 5 def dress_code @dress_code end |
#from_price ⇒ Object
Returns the value of attribute from_price.
3 4 5 |
# File 'lib/golf_switch/course_info_course.rb', line 3 def from_price @from_price end |
#greens ⇒ Object
Returns the value of attribute greens.
4 5 6 |
# File 'lib/golf_switch/course_info_course.rb', line 4 def greens @greens end |
#handicaps ⇒ Object
Returns the value of attribute handicaps.
6 7 8 |
# File 'lib/golf_switch/course_info_course.rb', line 6 def handicaps @handicaps end |
#has_net_rates ⇒ Object
Returns the value of attribute has_net_rates.
5 6 7 |
# File 'lib/golf_switch/course_info_course.rb', line 5 def has_net_rates @has_net_rates end |
#has_trade ⇒ Object
Returns the value of attribute has_trade.
5 6 7 |
# File 'lib/golf_switch/course_info_course.rb', line 5 def has_trade @has_trade end |
#holes ⇒ Object
Returns the value of attribute holes.
4 5 6 |
# File 'lib/golf_switch/course_info_course.rb', line 4 def holes @holes end |
#imgs ⇒ Object
Returns the value of attribute imgs.
4 5 6 |
# File 'lib/golf_switch/course_info_course.rb', line 4 def imgs @imgs end |
#max_reward_points ⇒ Object
Returns the value of attribute max_reward_points.
3 4 5 |
# File 'lib/golf_switch/course_info_course.rb', line 3 def max_reward_points @max_reward_points end |
#note ⇒ Object
Returns the value of attribute note.
3 4 5 |
# File 'lib/golf_switch/course_info_course.rb', line 3 def note @note end |
#pars ⇒ Object
Returns the value of attribute pars.
6 7 8 |
# File 'lib/golf_switch/course_info_course.rb', line 6 def pars @pars end |
#payment_terms ⇒ Object
Returns the value of attribute payment_terms.
5 6 7 |
# File 'lib/golf_switch/course_info_course.rb', line 5 def payment_terms @payment_terms end |
#rating_cnt ⇒ Object
Returns the value of attribute rating_cnt.
3 4 5 |
# File 'lib/golf_switch/course_info_course.rb', line 3 def @rating_cnt end |
#score_card ⇒ Object
Returns the value of attribute score_card.
5 6 7 |
# File 'lib/golf_switch/course_info_course.rb', line 5 def score_card @score_card end |
#services ⇒ Object
Returns the value of attribute services.
4 5 6 |
# File 'lib/golf_switch/course_info_course.rb', line 4 def services @services end |
#short_promo ⇒ Object
Returns the value of attribute short_promo.
3 4 5 |
# File 'lib/golf_switch/course_info_course.rb', line 3 def short_promo @short_promo end |
#to_price ⇒ Object
Returns the value of attribute to_price.
3 4 5 |
# File 'lib/golf_switch/course_info_course.rb', line 3 def to_price @to_price end |
#yard_ages ⇒ Object
Returns the value of attribute yard_ages.
6 7 8 |
# File 'lib/golf_switch/course_info_course.rb', line 6 def yard_ages @yard_ages end |
#year_built ⇒ Object
Returns the value of attribute year_built.
4 5 6 |
# File 'lib/golf_switch/course_info_course.rb', line 4 def year_built @year_built end |
#zip ⇒ Object
Returns the value of attribute zip.
3 4 5 |
# File 'lib/golf_switch/course_info_course.rb', line 3 def zip @zip end |
Class Method Details
.parse_course(response_hash) ⇒ Object
68 69 70 |
# File 'lib/golf_switch/course_info_course.rb', line 68 def self.parse_course(response_hash) CourseInfoCourse.new(response_hash[:course].merge(:img_base=>response_hash[:img_base])) end |
Instance Method Details
#images(protocol = "https") ⇒ Object
72 73 74 75 76 77 78 |
# File 'lib/golf_switch/course_info_course.rb', line 72 def images(protocol="https") images = [] self.imgs.each do |img| images << build_url(img,protocol) end images end |
#no_of_allowed_player ⇒ Object
64 65 66 |
# File 'lib/golf_switch/course_info_course.rb', line 64 def no_of_allowed_player @allow_players.split("").count{|p| p=='Y'} end |
#parse_images(imgs) ⇒ Object
54 55 56 57 58 59 60 61 62 |
# File 'lib/golf_switch/course_info_course.rb', line 54 def parse_images(imgs) if imgs[:img].is_a?(Array) imgs[:img].each do |img| @imgs << img end elsif imgs[:img].is_a?(String) @imgs << imgs[:img] end end |
#parse_score_card(scores) ⇒ Object
42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/golf_switch/course_info_course.rb', line 42 def parse_score_card(scores) score_card =[] if scores.is_a?(Array) scores.each do |score| score_card << GolfSwitch::ScoreCard.new(score) end elsif scores.is_a?(Hash) score_card << GolfSwitch::ScoreCard.new(scores) end score_card end |
#set_course_image ⇒ Object
33 34 35 36 37 38 39 40 |
# File 'lib/golf_switch/course_info_course.rb', line 33 def set_course_image unless @imgs.grep(/overview/).blank? @img = @imgs.grep(/overview/).first else @img = @imgs[0] end end |