Class: HttpStub::Server::Stub::Response::File

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

Instance Attribute Summary collapse

Attributes inherited from Base

#body, #delay_in_seconds, #headers, #status

Instance Method Summary collapse

Methods inherited from Base

add_default_headers, #empty?, merge_defaults, #to_s, #type

Constructor Details

#initialize(args) ⇒ File

Returns a new instance of File.



12
13
14
15
16
# File 'lib/http_stub/server/stub/response/file.rb', line 12

def initialize(args)
  @file = args["body"][:tempfile]
  @uri = "file://#{@file.path}"
  super(args.merge("body" => ""))
end

Instance Attribute Details

#uriObject (readonly)

Returns the value of attribute uri.



10
11
12
# File 'lib/http_stub/server/stub/response/file.rb', line 10

def uri
  @uri
end

Instance Method Details

#serve_on(server) ⇒ Object



18
19
20
# File 'lib/http_stub/server/stub/response/file.rb', line 18

def serve_on(server)
  server.send_file(@file.path, send_options)
end