Class: Scratchpad::Page
- Inherits:
-
Object
- Object
- Scratchpad::Page
- Defined in:
- lib/scratchpad/page.rb
Instance Method Summary collapse
- #add(content) ⇒ Object
-
#initialize(env) ⇒ Page
constructor
A new instance of Page.
- #to_html ⇒ Object
Constructor Details
#initialize(env) ⇒ Page
Returns a new instance of Page.
3 4 5 |
# File 'lib/scratchpad/page.rb', line 3 def initialize env env[:scratchpad] = self end |
Instance Method Details
#add(content) ⇒ Object
7 8 9 10 |
# File 'lib/scratchpad/page.rb', line 7 def add content file, line = *caller[1].split(':') (@content ||= []) << { content: content.dup, file: file, line: line } end |
#to_html ⇒ Object
12 13 14 15 16 17 18 |
# File 'lib/scratchpad/page.rb', line 12 def to_html return "" unless @content ActionView::Base.new(File.dirname(__FILE__)+"../../../app/views").render( file: "scratchpad.html.erb", locals: { content: @content } ) end |