Class: WebConsole::Controller

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

Constant Summary collapse

WEBCONSOLE_CONSTANTS =
File.join(File.dirname(__FILE__), "constants")
CSS_EXTENSION =
".css"
CSS_PATH_COMPONENT =
"css/"
JS_EXTENSION =
".js"
JS_PATH_COMPONENT =
"js/"

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(delegate = nil, erb_template_path = nil) ⇒ Controller

Returns a new instance of Controller.



11
12
13
14
15
16
17
18
19
20
# File 'lib/webconsole/controller.rb', line 11

def initialize(delegate = nil, erb_template_path = nil)
  @delegate = delegate

  template_erb = ERB.new(File.new(erb_template_path).read, nil, '-')
  html = template_erb.result(binding)

  if @delegate
    @delegate.load_html(html)
  end
end

Instance Attribute Details

#nameObject (readonly)

Returns the value of attribute name.



10
11
12
# File 'lib/webconsole/controller.rb', line 10

def name
  @name
end

Instance Method Details

#shared_javascript_include_tag(resource) ⇒ Object



30
31
32
33
# File 'lib/webconsole/controller.rb', line 30

def shared_javascript_include_tag(resource)
  uri = URI.join(shared_resources_url, JS_PATH_COMPONENT, resource + JS_EXTENSION)
  return "<script type=\"text/javascript\" src=\"#{uri.to_s}\"></script>"
end


24
25
26
27
# File 'lib/webconsole/controller.rb', line 24

def shared_stylesheet_link_tag(resource)
  uri = URI.join(shared_resources_url, CSS_PATH_COMPONENT, resource + CSS_EXTENSION)
  return "<link rel=\"stylesheet\" href=\"#{uri.to_s}\" />"
end