Class: Rack::Ketai::Carrier::Abstract
- Inherits:
-
Object
- Object
- Rack::Ketai::Carrier::Abstract
- Defined in:
- lib/rack/ketai/carrier/abstract.rb
Constant Summary collapse
- USER_AGENT_REGEXP =
nil
Class Method Summary collapse
Instance Method Summary collapse
-
#cache_size ⇒ Object
キャッシュサイズ.
-
#deviceid ⇒ Object
デバイスID 端末毎にユニーク.
-
#display ⇒ Object
ディスプレイ情報.
- #filtering(env, options = { }, &block) ⇒ Object
- #filters(options = { }) ⇒ Object
-
#ident ⇒ Object
識別情報.
-
#initialize(env) ⇒ Abstract
constructor
A new instance of Abstract.
-
#mobile? ⇒ Boolean
携帯端末か.
-
#name ⇒ Object
機種名(略名).
-
#position ⇒ Object
位置情報.
- #request ⇒ Object
-
#smartphone? ⇒ Boolean
スマートフォンか.
-
#subscriberid ⇒ Object
サブスクライバID 契約者毎にユニーク.
-
#supports_cookie? ⇒ Boolean
Cookieのサポート.
-
#valid_addr? ⇒ Boolean
(also: #valid_ip?)
キャリアのIPアドレス帯を利用しているか.
Constructor Details
#initialize(env) ⇒ Abstract
Returns a new instance of Abstract.
77 78 79 |
# File 'lib/rack/ketai/carrier/abstract.rb', line 77 def initialize(env) @env = env end |
Class Method Details
.filters ⇒ Object
60 61 62 |
# File 'lib/rack/ketai/carrier/abstract.rb', line 60 def filters [] end |
.valid_addr?(remote_addr) ⇒ Boolean
64 65 66 67 68 69 70 71 72 73 |
# File 'lib/rack/ketai/carrier/abstract.rb', line 64 def valid_addr?(remote_addr) cidrs = nil begin cidrs = self::CIDRS rescue NameError return nil end remote = IPAddr.new(remote_addr) cidrs.any?{ |cidr| cidr.include?(remote) } end |
.valid_ip? ⇒ Boolean
74 75 76 77 78 79 80 81 82 83 |
# File 'lib/rack/ketai/carrier/abstract.rb', line 74 def valid_addr?(remote_addr) cidrs = nil begin cidrs = self::CIDRS rescue NameError return nil end remote = IPAddr.new(remote_addr) cidrs.any?{ |cidr| cidr.include?(remote) } end |
Instance Method Details
#cache_size ⇒ Object
キャッシュサイズ
149 150 151 |
# File 'lib/rack/ketai/carrier/abstract.rb', line 149 def cache_size nil end |
#deviceid ⇒ Object
デバイスID 端末毎にユニーク
118 119 120 |
# File 'lib/rack/ketai/carrier/abstract.rb', line 118 def deviceid nil end |
#display ⇒ Object
ディスプレイ情報
138 139 140 |
# File 'lib/rack/ketai/carrier/abstract.rb', line 138 def display Rack::Ketai::Display.new end |
#filtering(env, options = { }, &block) ⇒ Object
87 88 89 90 91 92 |
# File 'lib/rack/ketai/carrier/abstract.rb', line 87 def filtering(env, = { }, &block) env = [:disable_filter] ? env : filters().inject(env) { |env, filter| filter.inbound(env) } ret = block.call(env) ret = [:disable_filter] ? ret : filters().reverse.inject(ret) { |r, filter| filter.outbound(*r) } ret end |
#filters(options = { }) ⇒ Object
94 95 96 97 98 |
# File 'lib/rack/ketai/carrier/abstract.rb', line 94 def filters( = { }) self.class.filters.collect do |klass| klass.new() end end |
#ident ⇒ Object
識別情報
123 124 125 |
# File 'lib/rack/ketai/carrier/abstract.rb', line 123 def ident subscriberid || deviceid end |
#mobile? ⇒ Boolean
携帯端末か
101 102 103 |
# File 'lib/rack/ketai/carrier/abstract.rb', line 101 def mobile? false end |
#name ⇒ Object
機種名(略名)
128 129 130 |
# File 'lib/rack/ketai/carrier/abstract.rb', line 128 def name nil end |
#position ⇒ Object
位置情報
133 134 135 |
# File 'lib/rack/ketai/carrier/abstract.rb', line 133 def position nil end |
#request ⇒ Object
81 82 83 |
# File 'lib/rack/ketai/carrier/abstract.rb', line 81 def request @request ||= Rack::Request.new(@env) end |
#smartphone? ⇒ Boolean
スマートフォンか
106 107 108 |
# File 'lib/rack/ketai/carrier/abstract.rb', line 106 def smartphone? false end |
#subscriberid ⇒ Object
サブスクライバID 契約者毎にユニーク
112 113 114 |
# File 'lib/rack/ketai/carrier/abstract.rb', line 112 def subscriberid nil end |
#supports_cookie? ⇒ Boolean
Cookieのサポート
154 155 156 |
# File 'lib/rack/ketai/carrier/abstract.rb', line 154 def false end |
#valid_addr? ⇒ Boolean Also known as: valid_ip?
キャリアのIPアドレス帯を利用しているか
143 144 145 |
# File 'lib/rack/ketai/carrier/abstract.rb', line 143 def valid_addr? self.class.valid_ip? @env['HTTP_X_FORWARDED_FOR'] || @env['REMOTE_ADDR'] end |