Class WEBrick::HTTPVersion
In: lib/webrick/httpversion.rb
Parent: Object

Methods

<=>   convert   new   to_s  

Included Modules

Comparable

Attributes

major  [RW] 
minor  [RW] 

Public Class methods

[Source]

    # File lib/webrick/httpversion.rb, line 16
16:     def self.convert(version)
17:       version.is_a?(self) ? version : new(version)
18:     end

[Source]

    # File lib/webrick/httpversion.rb, line 20
20:     def initialize(version)
21:       case version
22:       when HTTPVersion
23:         @major, @minor = version.major, version.minor
24:       when String
25:         if /^(\d+)\.(\d+)$/ =~ version
26:           @major, @minor = $1.to_i, $2.to_i
27:         end
28:       end
29:       if @major.nil? || @minor.nil?
30:         raise ArgumentError,
31:           format("cannot convert %s into %s", version.class, self.class)
32:       end
33:     end

Public Instance methods

[Source]

    # File lib/webrick/httpversion.rb, line 35
35:     def <=>(other)
36:       unless other.is_a?(self.class)
37:         other = self.class.new(other)
38:       end
39:       if (ret = @major <=> other.major) == 0
40:         return @minor <=> other.minor
41:       end
42:       return ret
43:     end

[Source]

    # File lib/webrick/httpversion.rb, line 45
45:     def to_s
46:       format("%d.%d", @major, @minor)
47:     end

[Validate]