Class: TxghServer::StreamResponse

Inherits:
Object
  • Object
show all
Defined in:
lib/txgh-server/stream_response.rb

Direct Known Subclasses

TgzStreamResponse, ZipStreamResponse

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attachment, enum) ⇒ StreamResponse

Returns a new instance of StreamResponse.



7
8
9
10
# File 'lib/txgh-server/stream_response.rb', line 7

def initialize(attachment, enum)
  @attachment = attachment
  @enum = enum
end

Instance Attribute Details

#attachmentObject (readonly)

Returns the value of attribute attachment.



5
6
7
# File 'lib/txgh-server/stream_response.rb', line 5

def attachment
  @attachment
end

#enumObject (readonly)

Returns the value of attribute enum.



5
6
7
# File 'lib/txgh-server/stream_response.rb', line 5

def enum
  @enum
end

Instance Method Details

#errorObject



33
34
35
# File 'lib/txgh-server/stream_response.rb', line 33

def error
  nil
end

#file_extensionObject

Raises:

  • (NotImplementedError)


17
18
19
20
# File 'lib/txgh-server/stream_response.rb', line 17

def file_extension
  raise NotImplementedError,
    "please implement #{__method__} in derived classes"
end

#headersObject



22
23
24
25
26
27
# File 'lib/txgh-server/stream_response.rb', line 22

def headers
  @headers ||= {
    'Content-Disposition' => "attachment; filename=\"#{attachment}#{file_extension}\"",
    'Content-Type' => MIME::Types.type_for(file_extension).first.content_type
  }
end

#streaming?Boolean

Returns:

  • (Boolean)


29
30
31
# File 'lib/txgh-server/stream_response.rb', line 29

def streaming?
  true
end

#write_to(stream) ⇒ Object

Raises:

  • (NotImplementedError)


12
13
14
15
# File 'lib/txgh-server/stream_response.rb', line 12

def write_to(stream)
  raise NotImplementedError,
    "please implement #{__method__} in derived classes"
end