Class: HttpStub::Server::Stub::Response::FileBody
- Inherits:
-
Object
- Object
- HttpStub::Server::Stub::Response::FileBody
- Defined in:
- lib/http_stub/server/stub/response/file_body.rb
Instance Attribute Summary collapse
-
#uri ⇒ Object
readonly
Returns the value of attribute uri.
Instance Method Summary collapse
- #headers ⇒ Object
-
#initialize(hash) ⇒ FileBody
constructor
A new instance of FileBody.
- #serve(application, response) ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(hash) ⇒ FileBody
Returns a new instance of FileBody.
14 15 16 17 |
# File 'lib/http_stub/server/stub/response/file_body.rb', line 14 def initialize(hash) @path = hash.dig(:file, :path) @uri = "file://#{@path}" end |
Instance Attribute Details
#uri ⇒ Object (readonly)
Returns the value of attribute uri.
12 13 14 |
# File 'lib/http_stub/server/stub/response/file_body.rb', line 12 def uri @uri end |
Instance Method Details
#headers ⇒ Object
19 20 21 |
# File 'lib/http_stub/server/stub/response/file_body.rb', line 19 def headers DEFAULT_HEADERS end |
#serve(application, response) ⇒ Object
23 24 25 |
# File 'lib/http_stub/server/stub/response/file_body.rb', line 23 def serve(application, response) application.send_file(@path, (response)) end |
#to_s ⇒ Object
27 28 29 |
# File 'lib/http_stub/server/stub/response/file_body.rb', line 27 def to_s @uri end |