Class: ForgeryJa::Mobile

Inherits:
ForgeryJa show all
Defined in:
lib/forgery_ja/forgery_ja/mobile.rb

Constant Summary

Constants inherited from ForgeryJa

ARRAY, HIRA, H_KANA, KANA, KANJI, ROMA, VERSION

Class Method Summary collapse

Methods inherited from ForgeryJa

default_options, parse

Class Method Details

.docomo_ipObject

DocomoのIPアドレスを返します

返すIPはimode接続時のIPとなります
フルブラウザの場合は異なるIPとなるようです


107
108
109
# File 'lib/forgery_ja/forgery_ja/mobile.rb', line 107

def self.docomo_ip
  calc_ip( dictionaries[:docomo_ip].random ).join "."
end

.emoji_docomo_sjisObject

Docomoの絵文字をSjisで返します



74
75
76
# File 'lib/forgery_ja/forgery_ja/mobile.rb', line 74

def self.emoji_docomo_sjis
  emoji_docomo_unicode.encode("SJIS-DOCOMO")
end

.emoji_docomo_unicodeObject

Docomoの絵文字をUnicodeで返します



69
70
71
# File 'lib/forgery_ja/forgery_ja/mobile.rb', line 69

def self.emoji_docomo_unicode
  Emoji::Docomo.list.random
end

.emoji_google_unicodeObject

Googleの絵文字をUnicodeで返します



99
100
101
# File 'lib/forgery_ja/forgery_ja/mobile.rb', line 99

def self.emoji_google_unicode
  Emoji::Google.list.random
end

.emoji_kddi_sjisObject

Kddiの絵文字をSjisで返します



84
85
86
# File 'lib/forgery_ja/forgery_ja/mobile.rb', line 84

def self.emoji_kddi_sjis
  emoji_kddi_unicode.encode("SJIS-KDDI")
end

.emoji_kddi_unicodeObject

Kddiの絵文字をUnicodeで返します



79
80
81
# File 'lib/forgery_ja/forgery_ja/mobile.rb', line 79

def self.emoji_kddi_unicode
  Emoji::Kddi.list.random
end

.emoji_sjis(options = {}) ⇒ String

Return Sjis Emoji

optionsで指定したキャリアの絵文字をSjisで返します

Parameters:

  • options (Hash) (defaults to: {})

    キャリア指定

Options Hash (options):

  • :docomo (boolean) — default: true

    Docomo絵文字を返すかどうか

  • :kddi (boolean) — default: true

    Kddi絵文字を返すかどうか

  • :softbank (boolean) — default: true

    Softbank絵文字を返すかどうか

Returns:

  • (String)

    Sjis絵文字



29
30
31
32
33
34
35
36
# File 'lib/forgery_ja/forgery_ja/mobile.rb', line 29

def self.emoji_sjis(options={})
  options = { :docomo => true, :kddi => true, :softbank => true }.merge(options)
  list = []
  list << emoji_docomo_sjis if options[:docomo]
  list << emoji_kddi_sjis if options[:kddi]
  list << emoji_softbank_sjis if options[:softbank]
  list.random
end

.emoji_softbank_sjisObject

Softbankの絵文字をSjisで返します



94
95
96
# File 'lib/forgery_ja/forgery_ja/mobile.rb', line 94

def self.emoji_softbank_sjis
  emoji_softbank_unicode.encode("SJIS-SOFTBANK")
end

.emoji_softbank_unicodeObject

Softbankの絵文字をUnicodeで返します



89
90
91
# File 'lib/forgery_ja/forgery_ja/mobile.rb', line 89

def self.emoji_softbank_unicode
  Emoji::Softbank.list.random
end

.emoji_unicode(options = {}) ⇒ String

Return Unicode Emoji

optionsで指定したキャリアの絵文字をUnicodeで返します

Parameters:

  • options (Hash) (defaults to: {})

    キャリア指定

Options Hash (options):

  • :docomo (boolean) — default: true

    Docomo絵文字を返すかどうか

  • :kddi (boolean) — default: true

    Kddi絵文字を返すかどうか

  • :softbank (boolean) — default: true

    Softbank絵文字を返すかどうか

  • :google (boolean) — default: false

    Google絵文字を返すかどうか

Returns:

  • (String)

    Unicode絵文字



12
13
14
15
16
17
18
19
20
# File 'lib/forgery_ja/forgery_ja/mobile.rb', line 12

def self.emoji_unicode(options={})
  options = { :docomo => true, :kddi => true, :softbank => true, :google => false }.merge(options)
  list = []
  list << emoji_docomo_unicode if options[:docomo]
  list << emoji_kddi_unicode if options[:kddi]
  list << emoji_softbank_unicode if options[:softbank]
  list << emoji_google_unicode if options[:google]
  list.random
end

.ip(options = {}) ⇒ String

Returns Mobile IP

携帯電話から接続する際のIPアドレスを返します

Examples:

ForgeryJa(:mobile).ip
# => 124.146.175.254

Parameters:

  • options (Hash) (defaults to: {})

    キャリア指定

Options Hash (options):

  • :docomo (boolean) — default: true

    DocomoのIPを返すかどうか

  • :kddi (boolean) — default: true

    KddiのIPを返すかどうか

  • :softbank (boolean) — default: true

    SoftbankのIPを返すかどうか

Returns:

  • (String)

    ipアドレス



59
60
61
62
63
64
65
66
# File 'lib/forgery_ja/forgery_ja/mobile.rb', line 59

def self.ip(options={})
  options = { :docomo => true, :kddi => true, :softbank => true }.merge(options)
  list = []
  list << docomo_ip if options[:docomo]
  list << kddi_ip if options[:kddi]
  list << softbank_ip if options[:softbank]
  list.random
end

.kddi_ipObject

Kddiからの接続時のIPアドレスを返します

返すIPは EZweb接続時のIPとなります
PCサイトビューアー(PCSV)の際には異なるIPとなります
2011年7月にリストが増えるようです


116
117
118
# File 'lib/forgery_ja/forgery_ja/mobile.rb', line 116

def self.kddi_ip
  calc_ip( dictionaries[:kddi_ip].random ).join "."
end

.phone_number(options = {}) ⇒ String

Returns Mobile Phone Number in Japaneses

携帯電話番号を返します

Parameters:

  • options (Hash) (defaults to: {})

Options Hash (options):

  • :hyphen (boolean) — default: true

    ハイフンを含めるかどうか

Returns:

  • (String)


43
44
45
46
47
# File 'lib/forgery_ja/forgery_ja/mobile.rb', line 43

def self.phone_number(options={})
  options = {:hyphen => true}.merge(options)
  format = ( options[:hyphen] ? "-####-####" : "########" )
  ["090", "080", "070"].random + format.to_numbers
end

.softbank_ipObject

Softbankからの接続時のIPアドレスを返します

返すIPは Yahoo!ケータイからの接続時のIPとなります
PCサイトブラウザのIPアドレスは異なります
SSL接続時の仕様が変わるようです(http://creation.mb.softbank.jp/web/web_ssl.html)


125
126
127
# File 'lib/forgery_ja/forgery_ja/mobile.rb', line 125

def self.softbank_ip
  calc_ip( dictionaries[:softbank_ip].random ).join "."
end