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.
- #url ⇒ Object
- #url? ⇒ Boolean
-
#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 15 |
# File 'lib/gopher2000/request.rb', line 9 def initialize(raw, ip_addr=nil) @raw = raw @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
#url ⇒ Object
21 22 23 |
# File 'lib/gopher2000/request.rb', line 21 def url @raw.chomp.split("\t").first.gsub(/^URL\:/, '') end |
#url? ⇒ Boolean
17 18 19 |
# File 'lib/gopher2000/request.rb', line 17 def url? @raw =~ /^URL\:/ end |
#valid? ⇒ Boolean
confirm that this is actually a valid gopher request
27 28 29 30 |
# File 'lib/gopher2000/request.rb', line 27 def valid? # The Selector string should be no longer than 255 characters. (RFC 1436) @selector.length <= 255 end |