Skip to content

Instantly share code, notes, and snippets.

--- a/lib/jpmobile/mobile/abstract_mobile.rb
+++ b/lib/jpmobile/mobile/abstract_mobile.rb
@@ -48,6 +48,16 @@ module Jpmobile::Mobile
return false
end
+ # XXX: lib/jpmobile.rbのautoloadで先に各キャリアの定数を定義してるからできるよ
+ Jpmobile::Mobile.constants.each do |career|
+ next if self == Jpmobile::Mobile.const_get(career)
+ p career
index bdbaa13..7daa7e4 100644
--- a/lib/jpmobile/mobile/abstract_mobile.rb
+++ b/lib/jpmobile/mobile/abstract_mobile.rb
@@ -48,6 +48,15 @@ module Jpmobile::Mobile
return false
end
+ # XXX: lib/jpmobile.rbのautoloadで先に各キャリアの定数を定義してるからできるよ
+ Jpmobile::Mobile.constants.each do |career|
+ next if self == Jpmobile::Mobile.const_get(career)
voda = Jpmobile::Mobile::Vodafone.new({})
#=> #<Jpmobile::Mobile::Vodafone:0xb7bc0f18 @request={}>
voda.softbank?
#=> true
voda.vodafone?
#=> true
voda.jphone?
diff --git a/lib/jpmobile/mobile/abstract_mobile.rb b/lib/jpmobile/mobile/abstract_mobile.rb
index bdbaa13..2f88f11 100644
--- a/lib/jpmobile/mobile/abstract_mobile.rb
+++ b/lib/jpmobile/mobile/abstract_mobile.rb
@@ -48,6 +48,16 @@ module Jpmobile::Mobile
return false
end
+ # XXX: lib/jpmobile.rbのautoloadで先に各キャリアの定数を定義してるからできるよ
+ Jpmobile::Mobile.constants.each do |career|
diff --git a/lib/jpmobile/request_with_mobile.rb b/lib/jpmobile/request_with_mobile.rb
index e6f944c..720e646 100644
--- a/lib/jpmobile/request_with_mobile.rb
+++ b/lib/jpmobile/request_with_mobile.rb
@@ -24,8 +24,16 @@ module Jpmobile
end
# 携帯電話からであれば +true+を、そうでなければ +false+ を返す。
- def mobile?
- mobile != nil
require 'zipper'
require 'benchmark'
MAX = 5000
Benchmark.bm do |x|
x.report "zipper" do
original = Zipper.make(*(0..MAX).to_a)
zippers = (0..MAX).map{|i|
original.next.set(i)
}
diff --git a/lib/jpmobile.rb b/lib/jpmobile.rb
index 178ad7f..7e1e72d 100644
--- a/lib/jpmobile.rb
+++ b/lib/jpmobile.rb
@@ -15,6 +15,14 @@ module Jpmobile
autoload :Emobile, 'jpmobile/mobile/emobile'
autoload :Willcom, 'jpmobile/mobile/willcom'
autoload :Ddipocket, 'jpmobile/mobile/willcom'
+
+ def self.careers
# with ClassX::Declare
# cool!! thanks Naoto Takai
require 'classx'
#=> true
require 'classx/declare'
#=> true
include ClassX::Declare
require 'classx'
#=> true
require 'classx/util'
#=> true
class Hoge < ClassX
extend Util
require 'benchmark'
$LOAD_PATH.unshift(File.expand_path(File.join(File.dirname(__FILE__), '..', 'lib')))
require 'jpmobile'
USER_AGENTS = [
"KDDI-HI31 UP.Browser/6.2.0.5 (GUI) MMP/2.0",
"KDDI-HI31 UP.Browser/6.2.0.5.c.1.100 (GUI) MMP/2.0",
"KDDI-KC31 UP.Browser/6.2.0.5 (GUI) MMP/2.0",
"KDDI-KC22 UP.Browser/6.0.8.3 (GUI) MMP/1.1",