module Jpmobile::Helpers
携帯電話端末に位置情報を要求するための、特殊なリンクを出力するヘルパー群。 多くのキャリアでは特殊なFORMでも位置情報を要求できる。
Public Instance Methods
au_gps_link_to(str, options = {})
click to toggle source
au GPS位置情報を取得するためのリンクを返す。
# File lib/jpmobile/helpers.rb, line 112 def au_gps_link_to(str, options = {}) link_to_url(str, au_gps_url_for(options)) end
au_gps_url_for(options = {})
click to toggle source
au GPS位置情報を取得するためのURLを返す。
# File lib/jpmobile/helpers.rb, line 97 def au_gps_url_for(options = {}) url = options datum = 0 # 0:wgs84, 1:tokyo unit = 0 # 0:dms, 1:deg if options.is_a?(Hash) options = options.symbolize_keys options[:only_path] = false datum = (options.delete(:datum) || 0).to_i # 0:wgs84, 1:tokyo unit = (options.delete(:unit) || 0).to_i # 0:dms, 1:deg url = url_for(options) end "device:gpsone?url=#{CGI.escape(url)}&ver=1&datum=#{datum}&unit=#{unit}&acry=0&number=0" end
au_location_link_to(str, options = {})
click to toggle source
au 簡易位置情報を取得するためのリンクを返す。
# File lib/jpmobile/helpers.rb, line 128 def au_location_link_to(str, options = {}) link_to_url(str, au_location_url_for(options)) end
au_location_url_for(options = {})
click to toggle source
au 簡易位置情報を取得するためのURLを返す。
# File lib/jpmobile/helpers.rb, line 117 def au_location_url_for(options = {}) url = options if options.is_a?(Hash) options = options.symbolize_keys options[:only_path] = false url = url_for(options) end "device:location?url=#{CGI.escape(url)}" end
docomo_foma_gps_link_to(str, options = {})
click to toggle source
DoCoMo FOMAでGPS位置情報を取得するためのリンクを返す。
# File lib/jpmobile/helpers.rb, line 45 def docomo_foma_gps_link_to(str, options = {}) url = options if options.is_a?(Hash) options = options.symbolize_keys options[:only_path] = false url = url_for(options) end %(<a href="#{url}" lcs>#{str}</a>).html_safe end
docomo_guid_link_to(str, options = {})
click to toggle source
DoCoMoでiモードIDを取得するためのリンクを返す。
# File lib/jpmobile/helpers.rb, line 86 def docomo_guid_link_to(str, options = {}) url = options if options.is_a?(Hash) options = options.symbolize_keys options[:guid] = 'ON' url = url_for(options) end link_to_url(str, url) end
docomo_openiarea_link_to(str, options = {})
click to toggle source
DoCoMoでオープンiエリアを取得するためのリンクを返す。
# File lib/jpmobile/helpers.rb, line 70 def docomo_openiarea_link_to(str, options = {}) link_to_url(str, docomo_openiarea_url_for(options)) end
docomo_openiarea_url_for(options = {})
click to toggle source
DoCoMoでオープンiエリアを取得するためのURLを返す。
# File lib/jpmobile/helpers.rb, line 56 def docomo_openiarea_url_for(options = {}) url = options if options.is_a?(Hash) options = options.symbolize_keys options[:only_path] = false posinfo = options.delete(:posinfo) || '1' # 基地局情報を元に測位した緯度経度情報を要求 url = url_for(options) 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 = {})
click to toggle source
DoCoMoで端末製造番号等を取得するためのリンクを返す。
# File lib/jpmobile/helpers.rb, line 75 def docomo_utn_link_to(str, options = {}) url = options if options.is_a?(Hash) options = options.symbolize_keys options[:only_path] = false url = url_for(options) end %(<a href="#{url}" utn>#{str}</a>).html_safe end
get_position_link_to(str = nil, options = {})
click to toggle source
位置情報(緯度経度がとれるもの。オープンiエリアをのぞく)要求するリンクを作成する。 位置情報を受け取るページを url_for
に渡す引数の形式で options
に指定する。 :show_all => true
とするとキャリア判別を行わず全てキャリアのリンクを返す。 第1引数に文字列を与えるとその文字列をアンカーテキストにする。 第1引数がHashの場合はデフォルトのアンカーテキストを出力する。
# File lib/jpmobile/helpers.rb, line 11 def get_position_link_to(str = nil, options = {}) if str.is_a?(Hash) options = str str = nil end show_all = nil if options.is_a?(Hash) options = options.symbolize_keys show_all = options.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)', options) 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)', options) end if show_all || (!request.mobile.supports_gps? && request.mobile.supports_location?) s << au_location_link_to(str || 'au(antenna)', options) 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)', options) end if show_all || request.mobile.instance_of?(Mobile::Willcom) s << willcom_location_link_to(str || 'Willcom', options) end s.join("<br>\n").html_safe end
softbank_location_link_to(str, options = {})
click to toggle source
Softbank(含むVodafone 3G)で位置情報を取得するためのリンクを返す。
# File lib/jpmobile/helpers.rb, line 147 def softbank_location_link_to(str, options = {}) link_to_url(str, softbank_location_url_for(options)) end
softbank_location_url_for(options = {})
click to toggle source
Softbank(含むVodafone 3G)で位置情報を取得するためのURLを返す。
# File lib/jpmobile/helpers.rb, line 133 def softbank_location_url_for(options = {}) url = options mode = 'auto' if options.is_a?(Hash) options = options.symbolize_keys mode = options.delete(:mode) || 'auto' options[:only_path] = false url = url_for(options) end url.sub!(/\?/, '&') "location:#{mode}?url=#{url}" end
willcom_location_link_to(str, options = {})
click to toggle source
Willcom 基地局位置情報を取得するためのリンクを返す。
# File lib/jpmobile/helpers.rb, line 163 def willcom_location_link_to(str, options = {}) link_to_url(str, willcom_location_url_for(options)) end
willcom_location_url_for(options = {})
click to toggle source
Willcom 基地局位置情報を取得するためのURLを返す。
# File lib/jpmobile/helpers.rb, line 152 def willcom_location_url_for(options = {}) url = options if options.is_a?(Hash) options = options.symbolize_keys options[:only_path] = false url = url_for(options) end "http://location.request/dummy.cgi?my=#{url}&pos=$location" end
Private Instance Methods
link_to_url(str, url)
click to toggle source
外部へのリンク
# File lib/jpmobile/helpers.rb, line 170 def link_to_url(str, url) link_to str, url end