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.



83
84
85
# File 'lib/microstation/configuration.rb', line 83

def initialize(app)
  @app = app
end

Instance Method Details

#[](variable) ⇒ Object



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

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

  get(variable)
end

#[]=(key, value) ⇒ Object



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

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

#append(variable, value) ⇒ Object



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

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



136
137
138
# File 'lib/microstation/configuration.rb', line 136

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

#exists?(value) ⇒ Boolean

Returns:

  • (Boolean)


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

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

#expand(string) ⇒ Object



140
141
142
# File 'lib/microstation/configuration.rb', line 140

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

#prepend(variable, value) ⇒ Object



87
88
89
90
91
92
93
94
95
# File 'lib/microstation/configuration.rb', line 87

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



113
114
115
# File 'lib/microstation/configuration.rb', line 113

def remove_variable(variable)
  workspace.RemoveConfigurationVariable variable
end

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

Raises:



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

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

  set!(key, value)
end

#set!(key, value) ⇒ Object



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

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