Class: Mobox::Server::IndexServer
- Inherits:
-
Object
- Object
- Mobox::Server::IndexServer
- Defined in:
- lib/mobox/server.rb
Instance Attribute Summary collapse
-
#source_path ⇒ Object
Returns the value of attribute source_path.
Instance Method Summary collapse
- #call(env) ⇒ Object
- #content ⇒ Object
- #headers ⇒ Object
-
#initialize(path) ⇒ IndexServer
constructor
A new instance of IndexServer.
- #render_scope ⇒ Object
Constructor Details
#initialize(path) ⇒ IndexServer
Returns a new instance of IndexServer.
68 69 70 |
# File 'lib/mobox/server.rb', line 68 def initialize(path) self.source_path = Pathname(path) end |
Instance Attribute Details
#source_path ⇒ Object
Returns the value of attribute source_path.
66 67 68 |
# File 'lib/mobox/server.rb', line 66 def source_path @source_path end |
Instance Method Details
#call(env) ⇒ Object
72 73 74 |
# File 'lib/mobox/server.rb', line 72 def call(env) [200, headers, content] end |
#content ⇒ Object
84 85 86 |
# File 'lib/mobox/server.rb', line 84 def content Haml::Engine.new(File.open(source_path.join('index.haml'), File::RDONLY).read).render(render_scope) end |
#headers ⇒ Object
76 77 78 |
# File 'lib/mobox/server.rb', line 76 def headers {'Content-Type' => 'text/html', 'Cache-Control' => 'public, max-age=60'} end |
#render_scope ⇒ Object
80 81 82 |
# File 'lib/mobox/server.rb', line 80 def render_scope Mobox::RenderScope.new(source_path) end |