Class: Microstation::Configuration

Inherits:
Object
  • Object
show all
Defined in:
lib/microstation/configuration.rb

Instance Method Summary collapse

Constructor Details

#initialize(app) ⇒ Configuration

Returns a new instance of Configuration.



93
94
95
# File 'lib/microstation/configuration.rb', line 93

def initialize(app)
  @app = app
end

Instance Method Details

#[](variable) ⇒ Object



117
118
119
120
# File 'lib/microstation/configuration.rb', line 117

def [](variable)
  return nil unless exists? variable
  get(variable)
end

#[]=(key, value) ⇒ Object



138
139
140
# File 'lib/microstation/configuration.rb', line 138

def []=(key,value)
  set(key,value)
end

#append(variable, value) ⇒ Object



107
108
109
110
111
112
113
114
115
# File 'lib/microstation/configuration.rb', line 107

def append(variable,value)
  if exists?(variable)
    old_value = get(variable)
    new_value = "#{old_value};#{value}"
  else
    new_value = value.to_s
  end
  set!(variable,new_value)
end

#capabilities_allObject



146
147
148
# File 'lib/microstation/configuration.rb', line 146

def capabilities_all
  @workmode_all ||= Capabilities.new(self,'_USTN_CAPABILITY')
end

#exists?(value) ⇒ Boolean

Returns:

  • (Boolean)


142
143
144
# File 'lib/microstation/configuration.rb', line 142

def exists?(value)
  workspace.IsConfigurationVariableDefined(value)
end

#expand(string) ⇒ Object



151
152
153
# File 'lib/microstation/configuration.rb', line 151

def expand(string)
  workspace.ExpandConfigurationVariable(string)
end

#prepend(variable, value) ⇒ Object



97
98
99
100
101
102
103
104
105
# File 'lib/microstation/configuration.rb', line 97

def prepend(variable,value)
  if exists?(variable)
    old_value = get(variable)
    new_value = "#{value};#{old_value}"
  else
    new_value = value.to_s
  end
  set!(variable,new_value)
end

#remove_variable(variable) ⇒ Object



123
124
125
# File 'lib/microstation/configuration.rb', line 123

def remove_variable(variable)
  workspace.RemoveConfigurationVariable variable
end

#set(key, value, options = {}) ⇒ Object

Raises:



127
128
129
130
# File 'lib/microstation/configuration.rb', line 127

def set(key,value,options = {})
  raise VariableDefined unless should_update?(key,options)
  set!(key,value)
end

#set!(key, value) ⇒ Object



132
133
134
135
# File 'lib/microstation/configuration.rb', line 132

def set!(key,value)
  self.remove_variable(key)
  workspace.AddConfigurationVariable(key,value)
end