Class: S2P::NotebookRunner

Inherits:
Redcarpet::Render::HTML
  • Object
show all
Defined in:
lib/s2p/notebook.rb

Constant Summary collapse

MAIN_BINDING =
binding

Instance Method Summary collapse

Instance Method Details

#block_code(text, operation) ⇒ Object



42
43
44
45
46
47
48
49
50
51
# File 'lib/s2p/notebook.rb', line 42

def block_code(text, operation)
  case operation
  when nil, "ruby"
    eval(text, MAIN_BINDING) # See end of file for this hack.
  when "text"
    puts(text)
  end

  ""
end

#codespan(code) ⇒ Object



31
32
33
34
35
36
37
38
39
40
# File 'lib/s2p/notebook.rb', line 31

def codespan(code)
  case code
  when /^~ /
    eval(code[/^~ (.*)/, 1], MAIN_BINDING)
  else
    eval("puts(#{code})", MAIN_BINDING)
  end

  ""
end