class Jpmobile::Email

email関連の処理

Attributes

converting_content_type[W]
japanese_mail_address_regexp[W]

Public Class Methods

convertable?(content_type) click to toggle source
# File lib/jpmobile/email.rb, line 46
def convertable?(content_type)
  if converting_content_type.respond_to?(:each)
    converting_content_type.each do |c|
      return true if content_type.match?(c)
    end
  end

  nil
end
converting_content_type() click to toggle source
# File lib/jpmobile/email.rb, line 42
def converting_content_type
  @converting_content_type ||= ['text/plain', 'text/html']
end
detect(email) click to toggle source

メールアドレスよりキャリア情報を取得する

param1

email メールアドレス

return

Jpmobile::Mobileで定義されている携帯キャリアクラス

# File lib/jpmobile/email.rb, line 10
def detect(email)
  Mobile.carriers.each do |const|
    c = Mobile.const_get(const)
    return c if c::MAIL_ADDRESS_REGEXP && email.match(/^#{c::MAIL_ADDRESS_REGEXP}$/)
  end
  nil
end
detect_from_mail_header(header) click to toggle source

含まれているメールアドレスからキャリア情報を取得する

# File lib/jpmobile/email.rb, line 19
def detect_from_mail_header(header)
  Mobile.carriers.each do |const|
    c = Mobile.const_get(const)
    if c::MAIL_ADDRESS_REGEXP &&
       header.match(/(\S+@[A-Za-z0-9\-._]+)/) &&
       Regexp.last_match(1).match(/^#{c::MAIL_ADDRESS_REGEXP}$/)
      return c
    end
  end

  if japanese_mail?(header)
    return Jpmobile::Mobile::AbstractMobile
  end

  nil
end
japanese_mail?(header) click to toggle source
# File lib/jpmobile/email.rb, line 38
def japanese_mail?(header)
  @japanese_mail_address_regexp and header.match(@japanese_mail_address_regexp)
end