Module: Jpmobile::Helpers
- Defined in:
- lib/jpmobile/helpers.rb
Overview
携帯電話端末に位置情報を要求するための、特殊なリンクを出力するヘルパー群。 多くのキャリアでは特殊なFORMでも位置情報を要求できる。
Instance Method Summary collapse
-
#au_gps_link_to(str, options = {}) ⇒ Object
au GPS位置情報を取得するためのリンクを返す。.
-
#au_gps_url_for(options = {}) ⇒ Object
au GPS位置情報を取得するためのURLを返す。.
-
#au_location_link_to(str, options = {}) ⇒ Object
au 簡易位置情報を取得するためのリンクを返す。.
-
#au_location_url_for(options = {}) ⇒ Object
au 簡易位置情報を取得するためのURLを返す。.
-
#docomo_foma_gps_link_to(str, options = {}) ⇒ Object
DoCoMo FOMAでGPS位置情報を取得するためのリンクを返す。.
-
#docomo_guid_link_to(str, options = {}) ⇒ Object
DoCoMoでiモードIDを取得するためのリンクを返す。.
-
#docomo_openiarea_link_to(str, options = {}) ⇒ Object
DoCoMoでオープンiエリアを取得するためのリンクを返す。.
-
#docomo_openiarea_url_for(options = {}) ⇒ Object
DoCoMoでオープンiエリアを取得するためのURLを返す。.
-
#docomo_utn_link_to(str, options = {}) ⇒ Object
DoCoMoで端末製造番号等を取得するためのリンクを返す。.
-
#get_position_link_to(str = nil, options = {}) ⇒ Object
位置情報(緯度経度がとれるもの。オープンiエリアをのぞく)要求するリンクを作成する。 位置情報を受け取るページを
url_for
に渡す引数の形式でoptions
に指定する。 :show_all =>true
とするとキャリア判別を行わず全てキャリアのリンクを返す。 第1引数に文字列を与えるとその文字列をアンカーテキストにする。 第1引数がHashの場合はデフォルトのアンカーテキストを出力する。. -
#softbank_location_link_to(str, options = {}) ⇒ Object
Softbank(含むVodafone 3G)で位置情報を取得するためのリンクを返す。.
-
#softbank_location_url_for(options = {}) ⇒ Object
Softbank(含むVodafone 3G)で位置情報を取得するためのURLを返す。.
-
#willcom_location_link_to(str, options = {}) ⇒ Object
Willcom 基地局位置情報を取得するためのリンクを返す。.
-
#willcom_location_url_for(options = {}) ⇒ Object
Willcom 基地局位置情報を取得するためのURLを返す。.
Instance Method Details
#au_gps_link_to(str, options = {}) ⇒ Object
au GPS位置情報を取得するためのリンクを返す。
113 114 115 |
# File 'lib/jpmobile/helpers.rb', line 113 def au_gps_link_to(str, ={}) link_to_url(str, au_gps_url_for()) end |
#au_gps_url_for(options = {}) ⇒ Object
au GPS位置情報を取得するためのURLを返す。
98 99 100 101 102 103 104 105 106 107 108 109 110 |
# File 'lib/jpmobile/helpers.rb', line 98 def au_gps_url_for(={}) url = datum = 0 # 0:wgs84, 1:tokyo unit = 0 # 0:dms, 1:deg if .is_a?(Hash) = .symbolize_keys [:only_path] = false datum = (.delete(:datum) || 0 ).to_i # 0:wgs84, 1:tokyo unit = (.delete(:unit) || 0 ).to_i # 0:dms, 1:deg url = url_for() end return "device:gpsone?url=#{CGI.escape(url)}&ver=1&datum=#{datum}&unit=#{unit}&acry=0&number=0" end |
#au_location_link_to(str, options = {}) ⇒ Object
au 簡易位置情報を取得するためのリンクを返す。
129 130 131 |
# File 'lib/jpmobile/helpers.rb', line 129 def au_location_link_to(str, ={}) link_to_url(str, au_location_url_for()) end |
#au_location_url_for(options = {}) ⇒ Object
au 簡易位置情報を取得するためのURLを返す。
118 119 120 121 122 123 124 125 126 |
# File 'lib/jpmobile/helpers.rb', line 118 def au_location_url_for(={}) url = if .is_a?(Hash) = .symbolize_keys [:only_path] = false url = url_for() end return "device:location?url=#{CGI.escape(url)}" end |
#docomo_foma_gps_link_to(str, options = {}) ⇒ Object
DoCoMo FOMAでGPS位置情報を取得するためのリンクを返す。
46 47 48 49 50 51 52 53 54 |
# File 'lib/jpmobile/helpers.rb', line 46 def docomo_foma_gps_link_to(str, ={}) url = if .is_a?(Hash) = .symbolize_keys [:only_path] = false url = url_for() end return %{<a href="#{url}" lcs>#{str}</a>}.html_safe end |
#docomo_guid_link_to(str, options = {}) ⇒ Object
DoCoMoでiモードIDを取得するためのリンクを返す。
87 88 89 90 91 92 93 94 95 |
# File 'lib/jpmobile/helpers.rb', line 87 def docomo_guid_link_to(str, ={}) url = if .is_a?(Hash) = .symbolize_keys [:guid] = "ON" url = url_for() end return link_to_url(str, url) end |
#docomo_openiarea_link_to(str, options = {}) ⇒ Object
DoCoMoでオープンiエリアを取得するためのリンクを返す。
71 72 73 |
# File 'lib/jpmobile/helpers.rb', line 71 def docomo_openiarea_link_to(str, ={}) link_to_url(str, docomo_openiarea_url_for()) end |
#docomo_openiarea_url_for(options = {}) ⇒ Object
DoCoMoでオープンiエリアを取得するためのURLを返す。
57 58 59 60 61 62 63 64 65 66 67 68 |
# File 'lib/jpmobile/helpers.rb', line 57 def docomo_openiarea_url_for(={}) url = if .is_a?(Hash) = .symbolize_keys [:only_path] = false posinfo = .delete(:posinfo) || "1" # 基地局情報を元に測位した緯度経度情報を要求 url = url_for() else posinfo = "1" end return "http://w1m.docomo.ne.jp/cp/iarea?ecode=OPENAREACODE&msn=OPENAREAKEY&posinfo=#{posinfo}&nl=#{CGI.escape(url)}" end |
#docomo_utn_link_to(str, options = {}) ⇒ Object
DoCoMoで端末製造番号等を取得するためのリンクを返す。
76 77 78 79 80 81 82 83 84 |
# File 'lib/jpmobile/helpers.rb', line 76 def docomo_utn_link_to(str, ={}) url = if .is_a?(Hash) = .symbolize_keys [:only_path] = false url = url_for() end return %{<a href="#{url}" utn>#{str}</a>}.html_safe end |
#get_position_link_to(str = nil, options = {}) ⇒ Object
位置情報(緯度経度がとれるもの。オープンiエリアをのぞく)要求するリンクを作成する。 位置情報を受け取るページを
url_for
に渡す引数の形式で options
に指定する。 :show_all =>
true
とするとキャリア判別を行わず全てキャリアのリンクを返す。
第1引数に文字列を与えるとその文字列をアンカーテキストにする。 第1引数がHashの場合はデフォルトのアンカーテキストを出力する。
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/jpmobile/helpers.rb', line 12 def get_position_link_to(str=nil, ={}) if str.is_a?(Hash) = str str = nil end show_all = nil if .is_a?(Hash) = .symbolize_keys show_all = .delete(:show_all) end # TODO: コード汚い s = [] if show_all || request.mobile.instance_of?(Mobile::Docomo) s << docomo_foma_gps_link_to(str||"DoCoMo FOMA(GPS)", ) end if show_all || request.mobile.instance_of?(Mobile::Au) if show_all || request.mobile.supports_gps? s << au_gps_link_to(str||"au(GPS)", ) end if show_all || (!(request.mobile.supports_gps?) && request.mobile.supports_location?) s << au_location_link_to(str||"au(antenna)", ) end end if show_all || request.mobile.instance_of?(Mobile::Vodafone) || request.mobile.instance_of?(Mobile::Softbank) s << softbank_location_link_to(str||"Softbank 3G(GPS)", ) end if show_all || request.mobile.instance_of?(Mobile::Willcom) s << willcom_location_link_to(str||"Willcom", ) end return s.join("<br>\n").html_safe end |
#softbank_location_link_to(str, options = {}) ⇒ Object
Softbank(含むVodafone 3G)で位置情報を取得するためのリンクを返す。
148 149 150 |
# File 'lib/jpmobile/helpers.rb', line 148 def softbank_location_link_to(str,={}) link_to_url(str,softbank_location_url_for()) end |
#softbank_location_url_for(options = {}) ⇒ Object
Softbank(含むVodafone 3G)で位置情報を取得するためのURLを返す。
134 135 136 137 138 139 140 141 142 143 144 145 |
# File 'lib/jpmobile/helpers.rb', line 134 def softbank_location_url_for(={}) url = mode = "auto" if .is_a?(Hash) = .symbolize_keys mode = .delete(:mode) || "auto" [:only_path] = false url = url_for() end url.sub!(/\?/, '&') return "location:#{mode}?url=#{url}" end |
#willcom_location_link_to(str, options = {}) ⇒ Object
Willcom 基地局位置情報を取得するためのリンクを返す。
164 165 166 |
# File 'lib/jpmobile/helpers.rb', line 164 def willcom_location_link_to(str,={}) link_to_url(str, willcom_location_url_for()) end |
#willcom_location_url_for(options = {}) ⇒ Object
Willcom 基地局位置情報を取得するためのURLを返す。
153 154 155 156 157 158 159 160 161 |
# File 'lib/jpmobile/helpers.rb', line 153 def willcom_location_url_for(={}) url = if .is_a?(Hash) = .symbolize_keys [:only_path] = false url = url_for() end return "http://location.request/dummy.cgi?my=#{url}&pos=$location" end |