Class: Microstation::Configuration
- Inherits:
-
Object
- Object
- Microstation::Configuration
- Defined in:
- lib/microstation/configuration.rb
Instance Method Summary collapse
- #[](variable) ⇒ Object
- #[]=(key, value) ⇒ Object
- #exists?(value) ⇒ Boolean
- #expand(string) ⇒ Object
-
#initialize(app) ⇒ Configuration
constructor
A new instance of Configuration.
- #remove_variable(variable) ⇒ Object
- #set(key, value, options = {}) ⇒ Object
- #should_update?(key, options = {force: false}) ⇒ Boolean
- #value(variable) ⇒ Object
Constructor Details
#initialize(app) ⇒ Configuration
Returns a new instance of Configuration.
8 9 10 |
# File 'lib/microstation/configuration.rb', line 8 def initialize(app) @app = app end |
Instance Method Details
#[](variable) ⇒ Object
12 13 14 15 |
# File 'lib/microstation/configuration.rb', line 12 def [](variable) return nil unless exists? variable value(variable) end |
#[]=(key, value) ⇒ Object
33 34 35 |
# File 'lib/microstation/configuration.rb', line 33 def []=(key,value) set(key,value) end |
#exists?(value) ⇒ Boolean
41 42 43 |
# File 'lib/microstation/configuration.rb', line 41 def exists?(value) workspace.IsConfigurationVariableDefined(value) end |
#expand(string) ⇒ Object
45 46 47 |
# File 'lib/microstation/configuration.rb', line 45 def (string) workspace.ExpandConfigurationVariable(string) end |
#remove_variable(variable) ⇒ Object
23 24 25 |
# File 'lib/microstation/configuration.rb', line 23 def remove_variable(variable) workspace.RemoveConfigurationVariable variable end |
#set(key, value, options = {}) ⇒ Object
27 28 29 30 |
# File 'lib/microstation/configuration.rb', line 27 def set(key,value, = {}) raise Microstation::VariableDefined unless should_update?(key,) workspace.AddConfigurationVariable(key,value) end |
#should_update?(key, options = {force: false}) ⇒ Boolean
17 18 19 20 21 |
# File 'lib/microstation/configuration.rb', line 17 def should_update?(key,={force: false}) return true unless exists? key force = .fetch(:force){ false} return !!force end |
#value(variable) ⇒ Object
37 38 39 |
# File 'lib/microstation/configuration.rb', line 37 def value(variable) workspace.ConfigurationVariableValue(variable) end |