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
# File 'lib/scratchpad/page.rb', line 7

def add content
  (@content ||= []) << content
end

#to_htmlObject



11
12
13
14
15
16
17
18
# File 'lib/scratchpad/page.rb', line 11

def to_html
  return "" unless @content
  %Q{ 
  <div id="scratchpad">
    #{@content.map { |i| "<div class='scratch'>#{i}</div>" }.join}
  </div>
  }
end