Permalink
Browse files

Moved class methods to the top of the class definition.

  • Loading branch information...
1 parent b38475c commit c703a2d3d78256f4ca2f99d9347fa04bf83da139 @jnunemaker committed Jun 21, 2011
Showing with 42 additions and 42 deletions.
  1. +42 −42 lib/user_agent.rb
View
@@ -1,46 +1,4 @@
class UserAgent
- attr_reader :string
-
- def initialize(string)
- @string = string.strip
- end
-
- def name
- self.class.name_for_user_agent(string)
- end
-
- def version
- self.class.version_for_user_agent(string)
- end
-
- def engine
- self.class.engine_for_user_agent(string)
- end
-
- def engine_version
- self.class.engine_version_for_user_agent(string)
- end
-
- def os
- self.class.os_for_user_agent(string)
- end
-
- def platform
- self.class.platform_for_user_agent(string)
- end
-
- def to_s
- string
- end
-
- def inspect
- "#<UserAgent:#{name} version:#{version.inspect} engine:\"#{engine.to_s}:#{engine_version}\" os:#{os.to_s.inspect}>"
- end
-
- def ==(other)
- string == other.string
- end
-
def self.engine_version_for_user_agent(string)
if string =~ /#{engine_for_user_agent(string)}[\/ ]([\d\w\.\-]+)/i
$1
@@ -114,4 +72,46 @@ def self.platform_for_user_agent(string)
else :unknown
end
end
+
+ attr_reader :string
+
+ def initialize(string)
+ @string = string.strip
+ end
+
+ def name
+ self.class.name_for_user_agent(string)
+ end
+
+ def version
+ self.class.version_for_user_agent(string)
+ end
+
+ def engine
+ self.class.engine_for_user_agent(string)
+ end
+
+ def engine_version
+ self.class.engine_version_for_user_agent(string)
+ end
+
+ def os
+ self.class.os_for_user_agent(string)
+ end
+
+ def platform
+ self.class.platform_for_user_agent(string)
+ end
+
+ def to_s
+ string
+ end
+
+ def inspect
+ "#<UserAgent:#{name} version:#{version.inspect} engine:\"#{engine.to_s}:#{engine_version}\" os:#{os.to_s.inspect}>"
+ end
+
+ def ==(other)
+ string == other.string
+ end
end

0 comments on commit c703a2d

Please sign in to comment.