Class: ActionPrinter
- Inherits:
-
ActionView::Base
- Object
- ActionView::Base
- ActionPrinter
show all
- Defined in:
- lib/action_printer.rb
Overview
Instance Attribute Summary collapse
Instance Method Summary
collapse
Constructor Details
#initialize(printer, paper) ⇒ ActionPrinter
18
19
20
21
22
|
# File 'lib/action_printer.rb', line 18
def initialize(printer,paper)
@printer=printer
@paper=paper
super(Rails.configuration.paths['app/views'])
end
|
Instance Attribute Details
#paper ⇒ Object
prepend_view_path ViewTemplate::Resolver.instance
16
17
18
|
# File 'lib/action_printer.rb', line 16
def paper
@paper
end
|
#printer ⇒ Object
prepend_view_path ViewTemplate::Resolver.instance
16
17
18
|
# File 'lib/action_printer.rb', line 16
def printer
@printer
end
|
Instance Method Details
#command ⇒ Object
24
25
26
|
# File 'lib/action_printer.rb', line 24
def command
@printer.command
end
|
#file_path ⇒ Object
52
53
54
|
# File 'lib/action_printer.rb', line 52
def file_path
raise "must be implemented on the driver!!"
end
|
#get_file_type ⇒ Object
64
65
66
|
# File 'lib/action_printer.rb', line 64
def get_file_type
raise "you must implement this on the driver!!"
end
|
#html_file(str, type = 'html') ⇒ Object
build a temp file with the HTML string rendered and provided as argument str
40
41
42
43
44
45
46
|
# File 'lib/action_printer.rb', line 40
def html_file str, type='html'
f = Tempfile.new(['print', ".#{type}"])
f.puts str
f.close
Rails.logger.info "oxen: wrote #{f.path}"
f
end
|
#label_file_path ⇒ Object
56
57
58
|
# File 'lib/action_printer.rb', line 56
def label_file_path
@label_file_path ||= `mktemp -t lblXXXX`[0..-2]
end
|
#logit(log_type, msg) ⇒ Object
76
77
78
|
# File 'lib/action_printer.rb', line 76
def logit( log_type, msg )
Rails.logger.send(log_type, "[OXEN] #{Time.now} [#{log_type.to_s}] #{msg}")
end
|
#pdf_file_path ⇒ Object
60
61
62
|
# File 'lib/action_printer.rb', line 60
def pdf_file_path
@pdf_file_path ||= `mktemp -t pdfXXXX`[0..-2]
end
|
#send_print_file(context) ⇒ Object
68
69
70
71
72
73
74
|
# File 'lib/action_printer.rb', line 68
def send_print_file context
context.send_file pdf_file_path, filename: 'oxen_file', type: get_file_type, disposition: "attachment"
end
|
#text_file(str) ⇒ Object
48
49
50
|
# File 'lib/action_printer.rb', line 48
def text_file str
html_file str, 'label'
end
|