Class: Maidcafe::Moe

Inherits:
ResultItem show all
Defined in:
lib/ruby-maidcafe.rb

Defined Under Namespace

Classes: Baito, Coupon, Dayinfo, Event, Eventinfo, Newshop, Opendate, Shop

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from ResultItem

#element_text, #read

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

#addressObject

Returns the value of attribute address.



109
110
111
# File 'lib/ruby-maidcafe.rb', line 109

def address
  @address
end

#categoryObject

Returns the value of attribute category.



109
110
111
# File 'lib/ruby-maidcafe.rb', line 109

def category
  @category
end

#descriptionObject

Returns the value of attribute description.



109
110
111
# File 'lib/ruby-maidcafe.rb', line 109

def description
  @description
end

#gpsObject

Returns the value of attribute gps.



109
110
111
# File 'lib/ruby-maidcafe.rb', line 109

def gps
  @gps
end

#imagesObject

Returns the value of attribute images.



109
110
111
# File 'lib/ruby-maidcafe.rb', line 109

def images
  @images
end

#map_urlsObject

Returns the value of attribute map_urls.



109
110
111
# File 'lib/ruby-maidcafe.rb', line 109

def map_urls
  @map_urls
end

#nameObject

Returns the value of attribute name.



109
110
111
# File 'lib/ruby-maidcafe.rb', line 109

def name
  @name
end

#prefectureObject

Returns the value of attribute prefecture.



109
110
111
# File 'lib/ruby-maidcafe.rb', line 109

def prefecture
  @prefecture
end

#telObject

Returns the value of attribute tel.



109
110
111
# File 'lib/ruby-maidcafe.rb', line 109

def tel
  @tel
end

#urlObject

Returns the value of attribute url.



109
110
111
# File 'lib/ruby-maidcafe.rb', line 109

def url
  @url
end

#url_mobileObject

Returns the value of attribute url_mobile.



109
110
111
# File 'lib/ruby-maidcafe.rb', line 109

def url_mobile
  @url_mobile
end

#wgpsObject

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_tagObject



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_sObject



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