class Jpmobile::Mobile::Au
au携帯電話¶ ↑
CDMA 1X, CDMA 1X WINを含む。
Constants
- GPS_UNSUPPORTED_DEVICE_ID
GPS取得に対応していないデバイスID
- LOCATION_UNSUPPORTED_DEVICE_ID
簡易位置情報取得に対応していないデバイスID www.au.kddi.com/ezfactory/tec/spec/eznavi.html
- MAIL_ADDRESS_REGEXP
対応するメールアドレスの正規表現
- USER_AGENT_REGEXP
対応するUser-Agentの正規表現 User-Agent文字列中に “UP.Browser” を含むVodafoneの端末があるので注意が必要
Public Instance Methods
decoratable?()
click to toggle source
# File lib/jpmobile/mobile/au.rb, line 135 def decoratable? true end
default_charset()
click to toggle source
# File lib/jpmobile/mobile/au.rb, line 117 def default_charset 'Shift_JIS' end
device_id()
click to toggle source
デバイスIDを返す
# File lib/jpmobile/mobile/au.rb, line 55 def device_id if @request.env['HTTP_USER_AGENT'] =~ USER_AGENT_REGEXP Regexp.last_match(1) else nil end end
position()
click to toggle source
位置情報があれば Position
のインスタンスを返す。無ければ nil
を返す。
# File lib/jpmobile/mobile/au.rb, line 25 def position return @__posotion if defined? @__posotion return @__posotion = nil if params['lat'].nil? || params['lat'] == '' || params['lon'].nil? || params['lon'] == '' l = Jpmobile::Position.new l.options = params.select {|x, _| %w[ver datum unit lat lon alt time smaj smin vert majaa fm].include?(x) } case params['unit'] when '1' l.lat = params['lat'].to_f l.lon = params['lon'].to_f when '0', 'dms' raise 'Invalid dms form' unless params['lat'] =~ /^([+-]?\d+)\.(\d+)\.(\d+\.\d+)$/ l.lat = Jpmobile::Position.dms2deg(Regexp.last_match(1), Regexp.last_match(2), Regexp.last_match(3)) raise 'Invalid dms form' unless params['lon'] =~ /^([+-]?\d+)\.(\d+)\.(\d+\.\d+)$/ l.lon = Jpmobile::Position.dms2deg(Regexp.last_match(1), Regexp.last_match(2), Regexp.last_match(3)) else return @__posotion = nil end if params['datum'] == '1' # ただし、params["datum"]=="tokyo"のとき(簡易位置情報)のときは、 # 実際にはWGS84系のデータが渡ってくる # http://www.au.kddi.com/ezfactory/tec/spec/eznavi.html l.tokyo2wgs84! end @__posotion = l end
subno()
click to toggle source
EZ番号(サブスクライバID)があれば返す。無ければ nil
を返す。
# File lib/jpmobile/mobile/au.rb, line 19 def subno @request.env['HTTP_X_UP_SUBNO'] end
Also aliased as: ident_subscriber
supports_gps?()
click to toggle source
GPS位置情報取得に対応している場合は true
を返す。
# File lib/jpmobile/mobile/au.rb, line 69 def supports_gps? !GPS_UNSUPPORTED_DEVICE_ID.include?(device_id) end
supports_location?()
click to toggle source
簡易位置情報取得に対応している場合は true
を返す。
# File lib/jpmobile/mobile/au.rb, line 64 def supports_location? !LOCATION_UNSUPPORTED_DEVICE_ID.include?(device_id) end
to_external(str, content_type, charset)
click to toggle source
# File lib/jpmobile/mobile/au.rb, line 103 def to_external(str, content_type, charset) # UTF-8を数値参照に str = Jpmobile::Emoticon.utf8_to_unicodecr(str) # 文字コードを Shift_JIS に変換 if [nil, 'text/html', 'application/xhtml+xml'].include?(content_type) str = Jpmobile::Util.utf8_to_sjis(str) charset = default_charset unless str.empty? end # 数値参照を絵文字コードに変換 str = Jpmobile::Emoticon.unicodecr_to_external(str, Jpmobile::Emoticon::CONVERSION_TABLE_TO_AU, true) [str, charset] end
to_internal(str)
click to toggle source
文字コード変換
# File lib/jpmobile/mobile/au.rb, line 94 def to_internal(str) # 絵文字を数値参照に変換 str = Jpmobile::Emoticon.external_to_unicodecr_au(Jpmobile::Util.sjis(str)) # 文字コードを UTF-8 に変換 str = Jpmobile::Util.sjis_to_utf8(str) # 数値参照を UTF-8 に変換 Jpmobile::Emoticon.unicodecr_to_utf8(str) end
to_mail_body(str)
click to toggle source
メール送信用
# File lib/jpmobile/mobile/au.rb, line 122 def to_mail_body(str) to_mail_encoding(str) end
to_mail_internal(str, charset)
click to toggle source
# File lib/jpmobile/mobile/au.rb, line 126 def to_mail_internal(str, charset) if Jpmobile::Util.jis?(str) || Jpmobile::Util.ascii_8bit?(str) || (charset == mail_charset) # 絵文字を数値参照に変換 str = Jpmobile::Emoticon.external_to_unicodecr_au_mail(Jpmobile::Util.jis(str)) str = Jpmobile::Util.jis_to_utf8(Jpmobile::Util.jis_win(str)) end str end
Private Instance Methods
to_mail_encoding(str)
click to toggle source
# File lib/jpmobile/mobile/au.rb, line 141 def to_mail_encoding(str) str = Jpmobile::Emoticon.utf8_to_unicodecr(str) str = Jpmobile::Util.utf8_to_jis(str) Jpmobile::Util.jis(Jpmobile::Emoticon.unicodecr_to_au_email(str)) end