Class: UltraSettings::ApplicationView
- Inherits:
-
Object
- Object
- UltraSettings::ApplicationView
- Includes:
- RenderHelper
- Defined in:
- lib/ultra_settings/application_view.rb
Overview
This class can render information about all configurations. It is used by the bundled web UI, but you can use it to embed the configuration information in your own web pages.
The output will be a simple HTML drop down menu that can be used to select the configuration you want to see.
Instance Attribute Summary collapse
-
#css ⇒ Object
readonly
Returns the value of attribute css.
Instance Method Summary collapse
-
#initialize(color_scheme: :light) ⇒ ApplicationView
constructor
Initialize the application view with a color scheme.
-
#render(select_class: nil, table_class: nil) ⇒ String
Render the HTML for the configuration settings UI.
-
#style_tag ⇒ String
Generate an HTML style tag with the CSS for the view.
-
#to_s ⇒ String
Convert the view to a string by rendering it.
Methods included from RenderHelper
Constructor Details
#initialize(color_scheme: :light) ⇒ ApplicationView
Initialize the application view with a color scheme.
21 22 23 24 |
# File 'lib/ultra_settings/application_view.rb', line 21 def initialize(color_scheme: :light) @css = application_css(color_scheme) @css = @css.html_safe if @css.respond_to?(:html_safe) end |
Instance Attribute Details
#css ⇒ Object (readonly)
Returns the value of attribute css.
16 17 18 |
# File 'lib/ultra_settings/application_view.rb', line 16 def css @css end |
Instance Method Details
#render(select_class: nil, table_class: nil) ⇒ String
Render the HTML for the configuration settings UI.
31 32 33 34 35 |
# File 'lib/ultra_settings/application_view.rb', line 31 def render(select_class: nil, table_class: nil) html = ViewHelper.erb_template("index.html.erb").result(binding) html = html.html_safe if html.respond_to?(:html_safe) html end |
#style_tag ⇒ String
Generate an HTML style tag with the CSS for the view.
40 41 42 43 44 |
# File 'lib/ultra_settings/application_view.rb', line 40 def style_tag tag = "<style type=\"text/css\">\n#{css}\n</style>" tag = tag.html_safe if tag.respond_to?(:html_safe) tag end |
#to_s ⇒ String
Convert the view to a string by rendering it.
49 50 51 |
# File 'lib/ultra_settings/application_view.rb', line 49 def to_s render end |