Class: Mobox::Server::IndexServer

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

Instance Attribute Summary collapse

Instance Method Summary collapse

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_pathObject

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

#contentObject



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

#headersObject



76
77
78
# File 'lib/mobox/server.rb', line 76

def headers
  {'Content-Type'  => 'text/html', 'Cache-Control' => 'public, max-age=60'}
end

#render_scopeObject



80
81
82
# File 'lib/mobox/server.rb', line 80

def render_scope
  Mobox::RenderScope.new(source_path)
end