Class: ConvenientService::Examples::Standard::RequestParams::Utils::HTTP::Request::ParsePath

Inherits:
Command
  • Object
show all
Defined in:
lib/convenient_service/examples/standard/request_params/utils/http/request/parse_path.rb

Overview

TODO: Specs.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(http_string:) ⇒ ParsePath

Returns a new instance of ParsePath.



16
17
18
# File 'lib/convenient_service/examples/standard/request_params/utils/http/request/parse_path.rb', line 16

def initialize(http_string:)
  @http_string = http_string
end

Instance Attribute Details

#http_stringObject (readonly)

Returns the value of attribute http_string.



14
15
16
# File 'lib/convenient_service/examples/standard/request_params/utils/http/request/parse_path.rb', line 14

def http_string
  @http_string
end

Instance Method Details

#callObject



24
25
26
27
28
29
30
31
32
# File 'lib/convenient_service/examples/standard/request_params/utils/http/request/parse_path.rb', line 24

def call
  webrick_request = ::WEBrick::HTTPRequest.new(::WEBrick::Config::HTTP)

  webrick_request.parse(::StringIO.new(http_string))

  webrick_request.path
rescue ::WEBrick::HTTPStatus::BadRequest
  nil
end