Class: Gopher::Request

Inherits:
Object
  • Object
show all
Defined in:
lib/gopher2000/request.rb

Overview

basic class for an incoming request

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#inputObject

Returns the value of attribute input.



7
8
9
# File 'lib/gopher2000/request.rb', line 7

def input
  @input
end

#ip_addressObject

Returns the value of attribute ip_address.



7
8
9
# File 'lib/gopher2000/request.rb', line 7

def ip_address
  @ip_address
end

#selectorObject

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

Returns:

  • (Boolean)

    true if the request is valid, false otherwise



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