Class: Maidcafe::Moe
- Inherits:
-
ResultItem
- Object
- ResultItem
- Maidcafe::Moe
- Defined in:
- lib/ruby-maidcafe.rb
Defined Under Namespace
Classes: Baito, Coupon, Dayinfo, Event, Eventinfo, Newshop, Opendate, Shop
Instance Attribute Summary collapse
-
#address ⇒ Object
Returns the value of attribute address.
-
#category ⇒ Object
Returns the value of attribute category.
-
#description ⇒ Object
Returns the value of attribute description.
-
#gps ⇒ Object
Returns the value of attribute gps.
-
#images ⇒ Object
Returns the value of attribute images.
-
#map_urls ⇒ Object
Returns the value of attribute map_urls.
-
#name ⇒ Object
Returns the value of attribute name.
-
#prefecture ⇒ Object
Returns the value of attribute prefecture.
-
#tel ⇒ Object
Returns the value of attribute tel.
-
#url ⇒ Object
Returns the value of attribute url.
-
#url_mobile ⇒ Object
Returns the value of attribute url_mobile.
-
#wgps ⇒ Object
Returns the value of attribute wgps.
Instance Method Summary collapse
- #attr_to_tag ⇒ Object
-
#initialize(type, xml) ⇒ Moe
constructor
A new instance of Moe.
- #method_missing(name, *args, &block) ⇒ Object
- #to_s ⇒ Object
Methods inherited from ResultItem
Constructor Details
#initialize(type, xml) ⇒ Moe
Returns a new instance of Moe.
112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 |
# File 'lib/ruby-maidcafe.rb', line 112 def initialize(type, xml) read(xml) @specialities = self.class.const_get(type.to_s.capitalize).new(xml) @images = [element_text(xml, 'image/image1'), element_text(xml, 'image/image2'), element_text(xml, 'image/image3')].compact @map_urls = [element_text(xml, 'map/map_livedoor'), element_text(xml, 'map/map_navitime'), element_text(xml, 'map/map_mapfan'), element_text(xml, 'map/map_mapion'), element_text(xml, 'map/map_googlemap'), element_text(xml, 'map/map_alps')].compact @gps = Location.new element_text(xml, 'gps_lat'), element_text(xml, 'gps_lon') @wgps = Location.new element_text(xml, 'wgps_lat'), element_text(xml, 'wgps_lon') end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(name, *args, &block) ⇒ Object
143 144 145 |
# File 'lib/ruby-maidcafe.rb', line 143 def method_missing(name, *args, &block) @specialities.send name, *args end |
Instance Attribute Details
#address ⇒ Object
Returns the value of attribute address.
109 110 111 |
# File 'lib/ruby-maidcafe.rb', line 109 def address @address end |
#category ⇒ Object
Returns the value of attribute category.
109 110 111 |
# File 'lib/ruby-maidcafe.rb', line 109 def category @category end |
#description ⇒ Object
Returns the value of attribute description.
109 110 111 |
# File 'lib/ruby-maidcafe.rb', line 109 def description @description end |
#gps ⇒ Object
Returns the value of attribute gps.
109 110 111 |
# File 'lib/ruby-maidcafe.rb', line 109 def gps @gps end |
#images ⇒ Object
Returns the value of attribute images.
109 110 111 |
# File 'lib/ruby-maidcafe.rb', line 109 def images @images end |
#map_urls ⇒ Object
Returns the value of attribute map_urls.
109 110 111 |
# File 'lib/ruby-maidcafe.rb', line 109 def map_urls @map_urls end |
#name ⇒ Object
Returns the value of attribute name.
109 110 111 |
# File 'lib/ruby-maidcafe.rb', line 109 def name @name end |
#prefecture ⇒ Object
Returns the value of attribute prefecture.
109 110 111 |
# File 'lib/ruby-maidcafe.rb', line 109 def prefecture @prefecture end |
#tel ⇒ Object
Returns the value of attribute tel.
109 110 111 |
# File 'lib/ruby-maidcafe.rb', line 109 def tel @tel end |
#url ⇒ Object
Returns the value of attribute url.
109 110 111 |
# File 'lib/ruby-maidcafe.rb', line 109 def url @url end |
#url_mobile ⇒ Object
Returns the value of attribute url_mobile.
109 110 111 |
# File 'lib/ruby-maidcafe.rb', line 109 def url_mobile @url_mobile end |
#wgps ⇒ Object
Returns the value of attribute wgps.
109 110 111 |
# File 'lib/ruby-maidcafe.rb', line 109 def wgps @wgps end |
Instance Method Details
#attr_to_tag ⇒ Object
128 129 130 131 132 |
# File 'lib/ruby-maidcafe.rb', line 128 def attr_to_tag {:name => 'shopname', :category => 'category', :prefecture => 'todouhuken', :description => 'setumei', :url => 'url', :url_mobile => 'url_mobile', :tel => 'tel', :address => 'address'} end |
#to_s ⇒ Object
134 135 136 137 138 139 140 141 |
# File 'lib/ruby-maidcafe.rb', line 134 def to_s ERB.new(<<-end_of_template).result(binding) 店名: <%= name %> 住所: <%= address %> Tel: <%= tel %> 説明: <%= description.gsub("\n", "\n ").chomp %> end_of_template end |