Class: Jpmobile::Mobile::Au
- Inherits:
-
AbstractMobile
- Object
- AbstractMobile
- Jpmobile::Mobile::Au
- Defined in:
- lib/jpmobile/mobile/au.rb
Overview
au携帯電話
CDMA 1X, CDMA 1X WINを含む。
Constant Summary collapse
- USER_AGENT_REGEXP =
対応するUser-Agentの正規表現User-Agent文字列中に “UP.Browser” を含むVodafoneの端末があるので注意が必要
%r{^(?:KDDI|UP.Browser/.+?)-(.+?) }- MAIL_ADDRESS_REGEXP =
対応するメールアドレスの正規表現
/.+@ezweb\.ne\.jp/- LOCATION_UNSUPPORTED_DEVICE_ID =
簡易位置情報取得に対応していないデバイスID www.au.kddi.com/ezfactory/tec/spec/eznavi.html
%w[PT21 TS25 KCTE TST9 KCU1 SYT5 KCTD TST8 TST7 KCTC SYT4 KCTB KCTA TST6 KCT9 TST5 TST4 KCT8 SYT3 KCT7 MIT1 MAT3 KCT6 TST3 KCT5 KCT4 SYT2 MAT1 MAT2 TST2 KCT3 KCT2 KCT1 TST1 SYT1].freeze
- GPS_UNSUPPORTED_DEVICE_ID =
GPS取得に対応していないデバイスID
%w[PT21 KC26 SN28 SN26 KC23 SA28 TS25 SA25 SA24 SN23 ST14 KC15 SN22 KC14 ST13 SN17 SY15 CA14 HI14 TS14 KC13 SN15 SN16 SY14 ST12 TS13 CA13 MA13 HI13 SN13 SY13 SN12 SN14 ST11 DN11 SY12 KCTE TST9 KCU1 SYT5 KCTD TST8 TST7 KCTC SYT4 KCTB KCTA TST6 KCT9 TST5 TST4 KCT8 SYT3 KCT7 MIT1 MAT3 KCT6 TST3 KCT5 KCT4 SYT2 MAT1 MAT2 TST2 KCT3 KCT2 KCT1 TST1 SYT1].freeze
- TARGET_PARAMS =
%w[ver datum unit lat lon alt time smaj smin vert majaa fm].freeze
Constants inherited from AbstractMobile
Jpmobile::Mobile::AbstractMobile::MAIL_CHARSET, Jpmobile::Mobile::AbstractMobile::MAIL_CONTENT_TRANSFER_ENCODING
Instance Attribute Summary
Attributes inherited from AbstractMobile
Instance Method Summary collapse
- #decoratable? ⇒ Boolean
- #default_charset ⇒ Object
-
#device_id ⇒ Object
デバイスIDを返す.
-
#position ⇒ Object
位置情報があれば Position のインスタンスを返す。無ければ
nilを返す。. -
#subno ⇒ Object
(also: #ident_subscriber)
EZ番号(サブスクライバID)があれば返す。無ければ
nilを返す。. -
#supports_cookie? ⇒ Boolean
cookieに対応しているか?.
-
#supports_gps? ⇒ Boolean
GPS位置情報取得に対応している場合は
trueを返す。. -
#supports_location? ⇒ Boolean
簡易位置情報取得に対応している場合は
trueを返す。. - #to_external(str, content_type, charset) ⇒ Object
-
#to_internal(str) ⇒ Object
文字コード変換.
-
#to_mail_body(str) ⇒ Object
メール送信用.
- #to_mail_internal(str, charset) ⇒ Object
Methods inherited from AbstractMobile
add_user_agent_regexp, #apply_filter?, #apply_params_filter?, carrier, check_carrier, #content_transfer_encoding, #decode_transfer_encoding, #decorated?, #display, #ident, #ident_device, #initialize, ip_address_class, #mail_charset, #mail_variants, #require_related_part?, #smart_phone?, #tablet?, #to_mail_body_encoded?, #to_mail_subject, #to_mail_subject_encoded?, user_agent_regexp, #utf8_to_mail_encode, valid_ip?, #valid_ip?, #variants
Constructor Details
This class inherits a constructor from Jpmobile::Mobile::AbstractMobile
Instance Method Details
#decoratable? ⇒ Boolean
133 134 135 |
# File 'lib/jpmobile/mobile/au.rb', line 133 def decoratable? true end |
#default_charset ⇒ Object
115 116 117 |
# File 'lib/jpmobile/mobile/au.rb', line 115 def default_charset 'Shift_JIS' end |
#device_id ⇒ Object
デバイスIDを返す
57 58 59 60 61 62 63 |
# File 'lib/jpmobile/mobile/au.rb', line 57 def device_id if @request.env['HTTP_USER_AGENT'] =~ USER_AGENT_REGEXP Regexp.last_match(1) else nil end end |
#position ⇒ Object
位置情報があれば Position のインスタンスを返す。無ければ nil を返す。
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/jpmobile/mobile/au.rb', line 27 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. = params.slice(*TARGET_PARAMS) 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 ⇒ Object Also known as: ident_subscriber
EZ番号(サブスクライバID)があれば返す。無ければ nil を返す。
21 22 23 |
# File 'lib/jpmobile/mobile/au.rb', line 21 def subno @request.env['HTTP_X_UP_SUBNO'] end |
#supports_cookie? ⇒ Boolean
cookieに対応しているか?
76 77 78 79 80 81 82 83 84 85 86 87 88 89 |
# File 'lib/jpmobile/mobile/au.rb', line 76 def protocol = begin if @request.respond_to?(:scheme) @request.scheme else @request.protocol end rescue 'none' end !protocol.start_with?('https') end |
#supports_gps? ⇒ Boolean
GPS位置情報取得に対応している場合は true を返す。
71 72 73 |
# File 'lib/jpmobile/mobile/au.rb', line 71 def supports_gps? !GPS_UNSUPPORTED_DEVICE_ID.include?(device_id) end |
#supports_location? ⇒ Boolean
簡易位置情報取得に対応している場合は true を返す。
66 67 68 |
# File 'lib/jpmobile/mobile/au.rb', line 66 def supports_location? !LOCATION_UNSUPPORTED_DEVICE_ID.include?(device_id) end |
#to_external(str, content_type, charset) ⇒ Object
101 102 103 104 105 106 107 108 109 110 111 112 113 |
# File 'lib/jpmobile/mobile/au.rb', line 101 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) ⇒ Object
文字コード変換
92 93 94 95 96 97 98 99 |
# File 'lib/jpmobile/mobile/au.rb', line 92 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) ⇒ Object
メール送信用
120 121 122 |
# File 'lib/jpmobile/mobile/au.rb', line 120 def to_mail_body(str) to_mail_encoding(str) end |
#to_mail_internal(str, charset) ⇒ Object
124 125 126 127 128 129 130 131 |
# File 'lib/jpmobile/mobile/au.rb', line 124 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 |