class Jpmobile::Mobile::Softbank

Softbank携帯電話

Vodafoneのスーパクラス。

Constants

MAIL_ADDRESS_REGEXP

対応するメールアドレスの正規表現 ディズニーモバイル対応

MAIL_CHARSET

メールのデフォルトのcharset

MAIL_CONTENT_TRANSFER_ENCODING

テキスト部分の content-transfer-encoding

USER_AGENT_REGEXP

対応するuser-agentの正規表現

Public Instance Methods

decoratable?() click to toggle source
# File lib/jpmobile/mobile/softbank.rb, line 88
def decoratable?
  true
end
ident_device()
Alias for: serial_number
ident_subscriber()
Alias for: x_jphone_uid
position() click to toggle source

位置情報があれば Position のインスタンスを返す。無ければ nil を返す。

# File lib/jpmobile/mobile/softbank.rb, line 30
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.options = params.select {|x, _| ['pos', 'geo', 'x-acr'].include?(x) }

  @__position = l
end
serial_number() click to toggle source

製造番号を返す。無ければ nil を返す。

# File lib/jpmobile/mobile/softbank.rb, line 17
def serial_number
  @request.env['HTTP_USER_AGENT'] =~ /SN(.+?) /
  Regexp.last_match(1)
end
Also aliased as: ident_device
to_external(str, content_type, charset) click to toggle source
# File lib/jpmobile/mobile/softbank.rb, line 57
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) click to toggle source

文字コード変換

# File lib/jpmobile/mobile/softbank.rb, line 50
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) click to toggle source

メール送信用

# File lib/jpmobile/mobile/softbank.rb, line 67
def to_mail_body(str)
  to_mail_encoding(str)
end
to_mail_body_encoded?(str) click to toggle source
# File lib/jpmobile/mobile/softbank.rb, line 84
def to_mail_body_encoded?(str)
  Jpmobile::Util.shift_jis?(str)
end
to_mail_internal(str, charset) click to toggle source
# File lib/jpmobile/mobile/softbank.rb, line 71
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() click to toggle source

UIDを返す。

# File lib/jpmobile/mobile/softbank.rb, line 24
def x_jphone_uid
  @request.env['HTTP_X_JPHONE_UID']
end
Also aliased as: ident_subscriber

Private Instance Methods

to_mail_encoding(str) click to toggle source
# File lib/jpmobile/mobile/softbank.rb, line 98
def to_mail_encoding(str)
  str = Jpmobile::Emoticon.utf8_to_unicodecr(str)
  str = Jpmobile::Util.utf8_to_sjis(str)
  Jpmobile::Emoticon.unicodecr_to_softbank_email(str)
end