Class: HttpStub::Server::Stub::Response::FileBody

Inherits:
Object
  • Object
show all
Defined in:
lib/http_stub/server/stub/response/file_body.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#uriObject (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

#headersObject


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, send_options(response))
end

#to_sObject


27
28
29
# File 'lib/http_stub/server/stub/response/file_body.rb', line 27

def to_s
  @uri
end