Skip to content
This repository has been archived by the owner on Feb 7, 2018. It is now read-only.

Commit

Permalink
Moved class methods to the top of the class definition.
Browse files Browse the repository at this point in the history
  • Loading branch information
jnunemaker committed Jun 21, 2011
1 parent b38475c commit c703a2d
Showing 1 changed file with 42 additions and 42 deletions.
84 changes: 42 additions & 42 deletions lib/user_agent.rb
Original file line number Original file line Diff line number Diff line change
@@ -1,46 +1,4 @@
class UserAgent 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) def self.engine_version_for_user_agent(string)
if string =~ /#{engine_for_user_agent(string)}[\/ ]([\d\w\.\-]+)/i if string =~ /#{engine_for_user_agent(string)}[\/ ]([\d\w\.\-]+)/i
$1 $1
Expand Down Expand Up @@ -114,4 +72,46 @@ def self.platform_for_user_agent(string)
else :unknown else :unknown
end end
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 end

0 comments on commit c703a2d

Please sign in to comment.