Class: Jpmobile::Mobile::Softbank
- Inherits:
-
AbstractMobile
- Object
- AbstractMobile
- Jpmobile::Mobile::Softbank
- Defined in:
- lib/jpmobile/mobile/softbank.rb
Overview
Softbank携帯電話
Vodafoneのスーパクラス。
Direct Known Subclasses
Constant Summary collapse
- USER_AGENT_REGEXP =
対応するuser-agentの正規表現
/^(?:SoftBank|Semulator)/- MAIL_ADDRESS_REGEXP =
対応するメールアドレスの正規表現 ディズニーモバイル対応
/.+@(?:softbank\.ne\.jp|disney\.ne\.jp)/- MAIL_CHARSET =
メールのデフォルトのcharset
'Shift_JIS'.freeze
- MAIL_CONTENT_TRANSFER_ENCODING =
テキスト部分の content-transfer-encoding
'8bit'.freeze
- TARGET_PARAMS =
['pos', 'geo', 'x-acr'].freeze
Instance Attribute Summary
Attributes inherited from AbstractMobile
Instance Method Summary collapse
- #decoratable? ⇒ Boolean
-
#position ⇒ Object
位置情報があれば Position のインスタンスを返す。無ければ
nilを返す。. - #require_related_part? ⇒ Boolean
-
#serial_number ⇒ Object
(also: #ident_device)
製造番号を返す。無ければ
nilを返す。. -
#supports_cookie? ⇒ Boolean
cookieに対応しているか?.
- #to_external(str, content_type, charset) ⇒ Object
-
#to_internal(str) ⇒ Object
文字コード変換.
-
#to_mail_body(str) ⇒ Object
メール送信用.
- #to_mail_body_encoded?(str) ⇒ Boolean
- #to_mail_internal(str, charset) ⇒ Object
-
#x_jphone_uid ⇒ Object
(also: #ident_subscriber)
UIDを返す。.
Methods inherited from AbstractMobile
add_user_agent_regexp, #apply_filter?, #apply_params_filter?, carrier, check_carrier, #content_transfer_encoding, #decode_transfer_encoding, #decorated?, #default_charset, #display, #ident, #initialize, ip_address_class, #mail_charset, #mail_variants, #smart_phone?, #tablet?, #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
90 91 92 |
# File 'lib/jpmobile/mobile/softbank.rb', line 90 def decoratable? true end |
#position ⇒ Object
位置情報があれば Position のインスタンスを返す。無ければ nil を返す。
32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/jpmobile/mobile/softbank.rb', line 32 def position return @__position if defined? @__position return @__position = nil unless params['pos'] =~ /^([NS])(\d+)\.(\d+)\.(\d+\.\d+)([WE])(\d+)\.(\d+)\.(\d+\.\d+)$/ raise 'Unsupported datum' if params['geo'] != 'wgs84' l = Jpmobile::Position.new l.lat = ((Regexp.last_match(1) == 'N') ? 1 : -1) * Jpmobile::Position.dms2deg(Regexp.last_match(2), Regexp.last_match(3), Regexp.last_match(4)) l.lon = ((Regexp.last_match(5) == 'E') ? 1 : -1) * Jpmobile::Position.dms2deg(Regexp.last_match(6), Regexp.last_match(7), Regexp.last_match(8)) l. = params.slice(*TARGET_PARAMS) @__position = l end |
#require_related_part? ⇒ Boolean
94 95 96 |
# File 'lib/jpmobile/mobile/softbank.rb', line 94 def true end |
#serial_number ⇒ Object Also known as: ident_device
製造番号を返す。無ければ nil を返す。
19 20 21 22 |
# File 'lib/jpmobile/mobile/softbank.rb', line 19 def serial_number @request.env['HTTP_USER_AGENT'] =~ /SN(.+?) / Regexp.last_match(1) end |
#supports_cookie? ⇒ Boolean
cookieに対応しているか?
47 48 49 |
# File 'lib/jpmobile/mobile/softbank.rb', line 47 def true end |
#to_external(str, content_type, charset) ⇒ Object
59 60 61 62 63 64 65 66 |
# File 'lib/jpmobile/mobile/softbank.rb', line 59 def to_external(str, content_type, charset) # UTF-8を数値参照に str = Jpmobile::Emoticon.utf8_to_unicodecr(str) # 数値参照を絵文字コードに変換 str = Jpmobile::Emoticon.unicodecr_to_external(str, Jpmobile::Emoticon::CONVERSION_TABLE_TO_SOFTBANK, false) [str, charset] end |
#to_internal(str) ⇒ Object
文字コード変換
52 53 54 55 56 57 |
# File 'lib/jpmobile/mobile/softbank.rb', line 52 def to_internal(str) # 絵文字を数値参照に変換 str = Jpmobile::Emoticon.external_to_unicodecr_softbank(Jpmobile::Util.utf8(str)) # 数値参照を UTF-8 に変換 Jpmobile::Emoticon.unicodecr_to_utf8(str) end |
#to_mail_body(str) ⇒ Object
メール送信用
69 70 71 |
# File 'lib/jpmobile/mobile/softbank.rb', line 69 def to_mail_body(str) to_mail_encoding(str) end |
#to_mail_body_encoded?(str) ⇒ Boolean
86 87 88 |
# File 'lib/jpmobile/mobile/softbank.rb', line 86 def to_mail_body_encoded?(str) Jpmobile::Util.shift_jis?(str) end |
#to_mail_internal(str, charset) ⇒ Object
73 74 75 76 77 78 79 80 81 82 83 84 |
# File 'lib/jpmobile/mobile/softbank.rb', line 73 def to_mail_internal(str, charset) # 絵文字を数値参照に変換 if Jpmobile::Util.utf8?(str) || (charset == 'UTF-8') # UTF-8 str = Jpmobile::Emoticon.external_to_unicodecr_softbank(Jpmobile::Util.utf8(str)) elsif Jpmobile::Util.shift_jis?(str) || Jpmobile::Util.ascii_8bit?(str) || (charset == mail_charset) # Shift_JIS str = Jpmobile::Emoticon.external_to_unicodecr_softbank_sjis(Jpmobile::Util.sjis(str)) end str end |
#x_jphone_uid ⇒ Object Also known as: ident_subscriber
UIDを返す。
26 27 28 |
# File 'lib/jpmobile/mobile/softbank.rb', line 26 def x_jphone_uid @request.env['HTTP_X_JPHONE_UID'] end |