Class: Txgh::Handlers::StreamResponse

Inherits:
Object
  • Object
show all
Defined in:
lib/txgh/handlers/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.



8
9
10
11
# File 'lib/txgh/handlers/stream_response.rb', line 8

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

Instance Attribute Details

#attachmentObject (readonly)

Returns the value of attribute attachment.



6
7
8
# File 'lib/txgh/handlers/stream_response.rb', line 6

def attachment
  @attachment
end

#enumObject (readonly)

Returns the value of attribute enum.



6
7
8
# File 'lib/txgh/handlers/stream_response.rb', line 6

def enum
  @enum
end

Instance Method Details

#errorObject



34
35
36
# File 'lib/txgh/handlers/stream_response.rb', line 34

def error
  nil
end

#file_extensionObject

Raises:

  • (NotImplementedError)


18
19
20
21
# File 'lib/txgh/handlers/stream_response.rb', line 18

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

#headersObject



23
24
25
26
27
28
# File 'lib/txgh/handlers/stream_response.rb', line 23

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)


30
31
32
# File 'lib/txgh/handlers/stream_response.rb', line 30

def streaming?
  true
end

#write_to(stream) ⇒ Object

Raises:

  • (NotImplementedError)


13
14
15
16
# File 'lib/txgh/handlers/stream_response.rb', line 13

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