Class: ZAssets::MemoryFile

Inherits:
Object
  • Object
show all
Defined in:
lib/zassets/memory_file.rb

Instance Method Summary collapse

Constructor Details

#initialize(file) ⇒ MemoryFile

Returns a new instance of MemoryFile.



3
4
5
# File 'lib/zassets/memory_file.rb', line 3

def initialize(file)
  @file = file
end

Instance Method Details

#bodyObject



14
15
16
# File 'lib/zassets/memory_file.rb', line 14

def body
  @content ||= @file.read
end

#call(env) ⇒ Object



18
19
20
# File 'lib/zassets/memory_file.rb', line 18

def call(env)
  [200, headers, [body]]
end

#headersObject



7
8
9
10
11
12
# File 'lib/zassets/memory_file.rb', line 7

def headers
  {
    'Content-Type'    => 'text/html',
    'Content-Length'  => body.length.to_s
  }
end