Class: Brut::FrontEnd::HttpStatus
- Inherits:
-
Object
- Object
- Brut::FrontEnd::HttpStatus
- Defined in:
- lib/brut/front_end/http_status.rb
Overview
Wrapper around an HTTP status, that can also normalize strings that contain status codes.
Instance Method Summary collapse
-
#==(other) ⇒ true|false
True if the other object has the same class as this and has the same numeric representation.
-
#initialize(number) ⇒ HttpStatus
constructor
Create an http status.
-
#to_i ⇒ Number
The value as a number.
-
#to_s ⇒ String
The value as a string.
Constructor Details
#initialize(number) ⇒ HttpStatus
Create an http status
9 10 11 12 13 14 15 |
# File 'lib/brut/front_end/http_status.rb', line 9 def initialize(number) number = number.to_i if ((number < 100) || (number > 599)) raise ArgumentError,"'#{number}' is not a known HTTP status code" end @number = number end |
Instance Method Details
#==(other) ⇒ true|false
Returns true if the other object has the same class as this and has the same numeric representation.
23 24 25 |
# File 'lib/brut/front_end/http_status.rb', line 23 def ==(other) self.class == other.class && self.to_i == other.to_i end |
#to_i ⇒ Number
Returns the value as a number.
18 19 |
# File 'lib/brut/front_end/http_status.rb', line 18 def to_i = @number # @return [String] the value as a string |
#to_s ⇒ String
Returns the value as a string.
20 |
# File 'lib/brut/front_end/http_status.rb', line 20 def to_s = to_i.to_s |