Class: Nebula::WebClient::Setting
- Inherits:
-
Object
- Object
- Nebula::WebClient::Setting
- Defined in:
- lib/nebula/webclient/setting.rb
Overview
The configuration of the Nebula Viewer, including its scale, the border and some other advanced configurations.
Instance Attribute Summary collapse
-
#border ⇒ Object
Returns the value of attribute border.
-
#height ⇒ Object
Returns the value of attribute height.
-
#language ⇒ Object
Returns the value of attribute language.
-
#menu_docking ⇒ Object
Returns the value of attribute menu_docking.
-
#render_mode ⇒ Object
Returns the value of attribute render_mode.
-
#width ⇒ Object
Returns the value of attribute width.
Instance Method Summary collapse
-
#initialize(args = {}) ⇒ Setting
constructor
A new instance of Setting.
-
#to_json(uri = nil) ⇒ String
Generate the JSON code of the setting.
-
#to_url_parameters(uri = nil) ⇒ String
Generate the url parameters to describe the settings.
Constructor Details
#initialize(args = {}) ⇒ Setting
Returns a new instance of Setting.
66 67 68 69 70 71 72 73 |
# File 'lib/nebula/webclient/setting.rb', line 66 def initialize(args = {}) @width = args[:width] || 640 @height = args[:height] || 480 @border = args[:border] || Border.new = args[:menu_docking] || :bottom @render_mode = args[:render_mode] || :realistic @language = args[:language] || :english end |
Instance Attribute Details
#border ⇒ Object
Returns the value of attribute border.
108 109 110 |
# File 'lib/nebula/webclient/setting.rb', line 108 def border @border end |
#height ⇒ Object
Returns the value of attribute height.
107 108 109 |
# File 'lib/nebula/webclient/setting.rb', line 107 def height @height end |
#language ⇒ Object
Returns the value of attribute language.
111 112 113 |
# File 'lib/nebula/webclient/setting.rb', line 111 def language @language end |
#menu_docking ⇒ Object
Returns the value of attribute menu_docking.
109 110 111 |
# File 'lib/nebula/webclient/setting.rb', line 109 def end |
#render_mode ⇒ Object
Returns the value of attribute render_mode.
110 111 112 |
# File 'lib/nebula/webclient/setting.rb', line 110 def render_mode @render_mode end |
#width ⇒ Object
Returns the value of attribute width.
106 107 108 |
# File 'lib/nebula/webclient/setting.rb', line 106 def width @width end |
Instance Method Details
#to_json(uri = nil) ⇒ String
Generate the JSON code of the setting.
93 94 95 96 97 98 99 100 101 102 103 104 |
# File 'lib/nebula/webclient/setting.rb', line 93 def to_json(uri = nil) s = '' s << '{width:' << Encoder.str(width) s << ',height:' << Encoder.str(height) s << ',border:' << Encoder.str(border) if border.width > 0 s << ',menuDocking:' << Encoder.str() if != :bottom s << ',renderMode:' << Encoder.str(RenderModes[render_mode]) if render_mode != :realistic s << ',language:' << Encoder.str(Languages[language]) if language != :english s << ',uri' << Encoder.js(uri) if uri s << '}' s end |
#to_url_parameters(uri = nil) ⇒ String
Generate the url parameters to describe the settings.
78 79 80 81 82 83 84 85 86 87 88 |
# File 'lib/nebula/webclient/setting.rb', line 78 def to_url_parameters(uri = nil) s = '' s << '?w=' << Encoder.str(width) s << '&h=' << Encoder.str(height) s << '&b=' << Encoder.url(border) if border.width > 0 s << '&m=' << Encoder.str() if != :bottom s << '&r=' << Encoder.str(RenderModes[render_mode]) if render_mode != :default s << '&l=' << Encoder.str(Languages[language]) if language != :english s << '&u=' << Encoder.url(uri) if uri s end |