aboutsummaryrefslogtreecommitdiffstats
path: root/lib/webrick/httpversion.rb
diff options
context:
space:
mode:
Diffstat (limited to 'lib/webrick/httpversion.rb')
-rw-r--r--lib/webrick/httpversion.rb28
1 files changed, 27 insertions, 1 deletions
diff --git a/lib/webrick/httpversion.rb b/lib/webrick/httpversion.rb
index 5cf0ee400d..cdfb957296 100644
--- a/lib/webrick/httpversion.rb
+++ b/lib/webrick/httpversion.rb
@@ -8,15 +8,33 @@
# $IPR: httpversion.rb,v 1.5 2002/09/21 12:23:37 gotoyuzo Exp $
module WEBrick
+
+ ##
+ # Represents an HTTP protocol version
+
class HTTPVersion
include Comparable
- attr_accessor :major, :minor
+ ##
+ # The major protocol version number
+
+ attr_accessor :major
+
+ ##
+ # The minor protocol version number
+
+ attr_accessor :minor
+
+ ##
+ # Converts +version+ into an HTTPVersion
def self.convert(version)
version.is_a?(self) ? version : new(version)
end
+ ##
+ # Creates a new HTTPVersion from +version+.
+
def initialize(version)
case version
when HTTPVersion
@@ -32,6 +50,10 @@ module WEBrick
end
end
+ ##
+ # Compares this version with +other+ according to the HTTP specification
+ # rules.
+
def <=>(other)
unless other.is_a?(self.class)
other = self.class.new(other)
@@ -42,6 +64,10 @@ module WEBrick
return ret
end
+ ##
+ # The HTTP version as show in the HTTP request and response. For example,
+ # "1.1"
+
def to_s
format("%d.%d", @major, @minor)
end