Class: Scratchpad::Page

Inherits:
Object
  • Object
show all
Defined in:
lib/scratchpad/page.rb

Instance Method Summary collapse

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_htmlObject



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