Class: Simp::Application

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

Instance Method Summary collapse

Instance Method Details

#call(env) ⇒ Object



6
7
8
9
10
# File 'lib/simp.rb', line 6

def call(env)
  [200, {"Content-Type" => "html"},
   [html(env["REQUEST_PATH"][1..-1])]
  ]
end

#html(file_name) ⇒ Object



20
21
22
23
24
25
26
27
# File 'lib/simp.rb', line 20

def html(file_name)
  puts file_name
  if File.exist?("#{file_name}.html.erb")
    render file_name
  else
    render_400
  end
end

#render(file_name) ⇒ Object



12
13
14
# File 'lib/simp.rb', line 12

def render(file_name)
  eval Erubi::Engine.new(File.read("#{file_name}.html.erb")).src
end

#render_400Object



16
17
18
# File 'lib/simp.rb', line 16

def render_400
  "Oops, the page you visited is not exist."
end