Class: Gopher::Request
- Inherits:
-
Object
- Object
- Gopher::Request
- Defined in:
- lib/gopher2000/request.rb
Overview
basic class for an incoming request
Instance Attribute Summary collapse
-
#input ⇒ Object
Returns the value of attribute input.
-
#ip_address ⇒ Object
Returns the value of attribute ip_address.
-
#selector ⇒ Object
Returns the value of attribute selector.
Instance Method Summary collapse
-
#initialize(raw, ip_addr = nil) ⇒ Request
constructor
A new instance of Request.
-
#valid? ⇒ Boolean
confirm that this is actually a valid gopher request.
Constructor Details
#initialize(raw, ip_addr = nil) ⇒ Request
Returns a new instance of Request.
9 10 11 12 13 14 |
# File 'lib/gopher2000/request.rb', line 9 def initialize(raw, ip_addr=nil) @selector, @input = raw.chomp.split("\t") @selector = Gopher::Application.sanitize_selector(@selector) @ip_address = ip_addr end |
Instance Attribute Details
#input ⇒ Object
Returns the value of attribute input.
7 8 9 |
# File 'lib/gopher2000/request.rb', line 7 def input @input end |
#ip_address ⇒ Object
Returns the value of attribute ip_address.
7 8 9 |
# File 'lib/gopher2000/request.rb', line 7 def ip_address @ip_address end |
#selector ⇒ Object
Returns the value of attribute selector.
7 8 9 |
# File 'lib/gopher2000/request.rb', line 7 def selector @selector end |
Instance Method Details
#valid? ⇒ Boolean
confirm that this is actually a valid gopher request
18 19 20 21 |
# File 'lib/gopher2000/request.rb', line 18 def valid? # The Selector string should be no longer than 255 characters. (RFC 1436) @selector.length <= 255 end |