Module: Rtf::Rails::RtfHelper
- Defined in:
- lib/rtf_rails.rb
Instance Method Summary collapse
Instance Method Details
#disposition(download, filename) ⇒ Object
17 18 19 20 21 22 |
# File 'lib/rtf_rails.rb', line 17 def disposition(download, filename) download = true if (filename && download == nil) disposition = download ? "attachment;" : "inline;" disposition += " filename=\"#{filename}\"" if filename headers["Content-Disposition"] = disposition end |
#rtf_document(opts = {}) {|rtf| ... } ⇒ Object
6 7 8 9 10 11 12 13 14 15 |
# File 'lib/rtf_rails.rb', line 6 def rtf_document(opts={}) download = opts.delete(:force_download) filename = opts.delete(:filename) rtf = RTF::Document.new(RTF::Font.new(RTF::Font::ROMAN, 'Times New Roman')) yield rtf if block_given? disposition(download, filename) if (download || filename) rtf.to_rtf end |