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位置情報を取得するためのリンクを返す。
112 113 114 |
# File 'lib/jpmobile/helpers.rb', line 112 def au_gps_link_to(str, = {}) link_to_url(str, au_gps_url_for()) end |
#au_gps_url_for(options = {}) ⇒ Object
au GPS位置情報を取得するためのURLを返す。
97 98 99 100 101 102 103 104 105 106 107 108 109 |
# File 'lib/jpmobile/helpers.rb', line 97 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 "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 簡易位置情報を取得するためのリンクを返す。
128 129 130 |
# File 'lib/jpmobile/helpers.rb', line 128 def au_location_link_to(str, = {}) link_to_url(str, au_location_url_for()) end |
#au_location_url_for(options = {}) ⇒ Object
au 簡易位置情報を取得するためのURLを返す。
117 118 119 120 121 122 123 124 125 |
# File 'lib/jpmobile/helpers.rb', line 117 def au_location_url_for( = {}) url = if .is_a?(Hash) = .symbolize_keys [:only_path] = false url = url_for() end "device:location?url=#{CGI.escape(url)}" end |
#docomo_foma_gps_link_to(str, options = {}) ⇒ Object
DoCoMo FOMAでGPS位置情報を取得するためのリンクを返す。
45 46 47 48 49 50 51 52 53 |
# File 'lib/jpmobile/helpers.rb', line 45 def docomo_foma_gps_link_to(str, = {}) url = if .is_a?(Hash) = .symbolize_keys [:only_path] = false url = url_for() end %(<a href="#{url}" lcs>#{str}</a>).html_safe end |
#docomo_guid_link_to(str, options = {}) ⇒ Object
DoCoMoでiモードIDを取得するためのリンクを返す。
86 87 88 89 90 91 92 93 94 |
# File 'lib/jpmobile/helpers.rb', line 86 def docomo_guid_link_to(str, = {}) url = if .is_a?(Hash) = .symbolize_keys [:guid] = 'ON' url = url_for() end link_to_url(str, url) end |
#docomo_openiarea_link_to(str, options = {}) ⇒ Object
DoCoMoでオープンiエリアを取得するためのリンクを返す。
70 71 72 |
# File 'lib/jpmobile/helpers.rb', line 70 def docomo_openiarea_link_to(str, = {}) link_to_url(str, docomo_openiarea_url_for()) end |
#docomo_openiarea_url_for(options = {}) ⇒ Object
DoCoMoでオープンiエリアを取得するためのURLを返す。
56 57 58 59 60 61 62 63 64 65 66 67 |
# File 'lib/jpmobile/helpers.rb', line 56 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 "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で端末製造番号等を取得するためのリンクを返す。
75 76 77 78 79 80 81 82 83 |
# File 'lib/jpmobile/helpers.rb', line 75 def docomo_utn_link_to(str, = {}) url = if .is_a?(Hash) = .symbolize_keys [:only_path] = false url = url_for() end %(<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の場合はデフォルトのアンカーテキストを出力する。
11 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 |
# File 'lib/jpmobile/helpers.rb', line 11 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 s.join("<br>\n").html_safe end |
#softbank_location_link_to(str, options = {}) ⇒ Object
Softbank(含むVodafone 3G)で位置情報を取得するためのリンクを返す。
147 148 149 |
# File 'lib/jpmobile/helpers.rb', line 147 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を返す。
133 134 135 136 137 138 139 140 141 142 143 144 |
# File 'lib/jpmobile/helpers.rb', line 133 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!('?', '&') "location:#{mode}?url=#{url}" end |
#willcom_location_link_to(str, options = {}) ⇒ Object
Willcom 基地局位置情報を取得するためのリンクを返す。
163 164 165 |
# File 'lib/jpmobile/helpers.rb', line 163 def willcom_location_link_to(str, = {}) link_to_url(str, willcom_location_url_for()) end |
#willcom_location_url_for(options = {}) ⇒ Object
Willcom 基地局位置情報を取得するためのURLを返す。
152 153 154 155 156 157 158 159 160 |
# File 'lib/jpmobile/helpers.rb', line 152 def willcom_location_url_for( = {}) url = if .is_a?(Hash) = .symbolize_keys [:only_path] = false url = url_for() end "http://location.request/dummy.cgi?my=#{url}&pos=$location" end |