class Rasti::Web::Headers
Constants
- CONTENT_TYPES
Public Class Methods
for_file(filename, attachment:true, charset:'utf-8')
click to toggle source
# File lib/rasti/web/headers.rb, line 21 def for_file(filename, attachment:true, charset:'utf-8') merge content_type(MIME::Types.of(filename).first.content_type, charset: charset), content_disposition(filename, attachment: attachment) end
Private Class Methods
content_disposition(filename, attachment:true)
click to toggle source
# File lib/rasti/web/headers.rb, line 32 def content_disposition(filename, attachment:true) args = [] args << 'attachment' if attachment args << "filename=\"#{File.basename(filename)}\"" {'Content-Disposition' => args.join("; ")} end
content_type(type, charset:'utf-8')
click to toggle source
# File lib/rasti/web/headers.rb, line 28 def content_type(type, charset:'utf-8') {'Content-Type' => "#{type}; charset=#{charset}"} end
merge(*poperties)
click to toggle source
# File lib/rasti/web/headers.rb, line 39 def merge(*poperties) poperties.inject({}) do |result, prop| result.merge prop end end