Class: Request

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

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(method, resource, version) ⇒ Request

Returns a new instance of Request.



4
5
6
7
8
# File 'lib/request.rb', line 4

def initialize(method, resource, version)
	@method = method
	@resource = resource
	@version = version
end

Instance Attribute Details

#methodObject (readonly)

Returns the value of attribute method.



2
3
4
# File 'lib/request.rb', line 2

def method
  @method
end

#resourceObject (readonly)

Returns the value of attribute resource.



2
3
4
# File 'lib/request.rb', line 2

def resource
  @resource
end

#versionObject (readonly)

Returns the value of attribute version.



2
3
4
# File 'lib/request.rb', line 2

def version
  @version
end

Class Method Details

.parse(string) ⇒ Object



10
11
12
13
14
# File 'lib/request.rb', line 10

def self.parse(string)
  pattern = /\A(?<method>\w+)\s+(?<resource>\S+)\s+(?<version>\S+)/
  match = pattern.match(string)
  Request.new(match["method"], match["resource"], match["version"])
end