class Jpmobile::Mobile::Docomo
DoCoMo携帯電話¶ ↑
Constants
- MAIL_ADDRESS_REGEXP
対応するメールアドレスの正規表現
- MAIL_CHARSET
メールのデフォルトのcharset
- MAIL_CONTENT_TRANSFER_ENCODING
テキスト部分の content-transfer-encoding
- USER_AGENT_REGEXP
対応するUser-Agentの正規表現
Public Instance Methods
areacode()
click to toggle source
オープンiエリアがあればエリアコードを String
で返す。無ければ nil
を返す。
# File lib/jpmobile/mobile/docomo.rb, line 16 def areacode if params['ACTN'] == 'OK' params['AREACODE'] else nil end end
decoratable?()
click to toggle source
# File lib/jpmobile/mobile/docomo.rb, line 127 def decoratable? true end
default_charset()
click to toggle source
# File lib/jpmobile/mobile/docomo.rb, line 101 def default_charset 'Shift_JIS' end
guid()
click to toggle source
iモードIDを返す。
# File lib/jpmobile/mobile/docomo.rb, line 63 def guid @env['HTTP_X_DCMGUID'] end
icc()
click to toggle source
FOMAカード製造番号があれば返す。無ければ nil
を返す。
# File lib/jpmobile/mobile/docomo.rb, line 57 def icc @env['HTTP_USER_AGENT'] =~ /icc([0-9a-zA-Z]{20})\)/ Regexp.last_match(1) end
ident_subscriber()
click to toggle source
iモードID, FOMAカード製造番号の順で調べ、あるものを返す。なければ nil
を返す。
# File lib/jpmobile/mobile/docomo.rb, line 68 def ident_subscriber guid || icc end
imode_browser_version()
click to toggle source
i-mode ブラウザのバージョンを返す。 labs.unoh.net/2009/07/i_20.html
# File lib/jpmobile/mobile/docomo.rb, line 137 def imode_browser_version case @request.env['HTTP_USER_AGENT'] when %r{^DoCoMo/1.0/} ver = '1.0' when %r{^DoCoMo/2.0 } @request.env['HTTP_USER_AGENT'] =~ / (\w+)\(c(\d+);/ model = Regexp.last_match(1) cache_size = Regexp.last_match(2).to_i ver = if cache_size >= 500 (%w[P03B P05B L01B].member?(model) ? '2.0LE' : '2.0') else '1.0' end else # DoCoMo/3.0以降等は、とりあえず非v1.0扱い ver = '2.0' end ver end
model_name()
click to toggle source
モデル名を返す。
# File lib/jpmobile/mobile/docomo.rb, line 160 def model_name case @env['HTTP_USER_AGENT'] when %r{^DoCoMo/2.0 (.+)\(}, %r{^DoCoMo/1.0/(.+?)/} Regexp.last_match(1) else nil end end
position()
click to toggle source
位置情報があれば Position
のインスタンスを返す。無ければ nil
を返す。
# File lib/jpmobile/mobile/docomo.rb, line 25 def position return @__position if defined? @__position lat = params['lat'] || params['LAT'] lon = params['lon'] || params['LON'] geo = params['geo'] || params['GEO'] return @__position = nil if lat.nil? || lat == '' || lon.nil? || lon == '' raise 'Unsuppoted datum' unless geo.casecmp('wgs84') pos = Jpmobile::Position.new raise 'Unsuppoted' unless lat =~ /^([+-]\d+)\.(\d+)\.(\d+\.\d+)/ pos.lat = Jpmobile::Position.dms2deg(Regexp.last_match(1), Regexp.last_match(2), Regexp.last_match(3)) raise 'Unsuppoted' unless lon =~ /^([+-]\d+)\.(\d+)\.(\d+\.\d+)/ pos.lon = Jpmobile::Position.dms2deg(Regexp.last_match(1), Regexp.last_match(2), Regexp.last_match(3)) @__position = pos end
serial_number()
click to toggle source
端末製造番号があれば返す。無ければ nil
を返す。
# File lib/jpmobile/mobile/docomo.rb, line 45 def serial_number case @env['HTTP_USER_AGENT'] when /ser([0-9a-zA-Z]{11})$/, # mova /ser([0-9a-zA-Z]{15});/ # FOMA Regexp.last_match(1) else nil end end
Also aliased as: ident_device
to_external(str, content_type, charset)
click to toggle source
# File lib/jpmobile/mobile/docomo.rb, line 87 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_DOCOMO, true) [str, charset] end
to_internal(str)
click to toggle source
文字コード変換
# File lib/jpmobile/mobile/docomo.rb, line 78 def to_internal(str) # 絵文字を数値参照に変換 str = Jpmobile::Emoticon.external_to_unicodecr_docomo(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/docomo.rb, line 106 def to_mail_body(str) to_external(str, nil, nil).first end
to_mail_body_encoded?(str)
click to toggle source
# File lib/jpmobile/mobile/docomo.rb, line 123 def to_mail_body_encoded?(str) Jpmobile::Util.shift_jis?(str) end
to_mail_encoding(str)
click to toggle source
# File lib/jpmobile/mobile/docomo.rb, line 110 def to_mail_encoding(str) to_external(str, nil, nil).first end
to_mail_internal(str, charset)
click to toggle source
# File lib/jpmobile/mobile/docomo.rb, line 114 def to_mail_internal(str, charset) if Jpmobile::Util.shift_jis?(str) || Jpmobile::Util.ascii_8bit?(str) || (charset == mail_charset) # 絵文字を数値参照に変換 str = Jpmobile::Emoticon.external_to_unicodecr_docomo(Jpmobile::Util.sjis(str)) end str end