Class: GMSEC::ConfigFile
- Inherits:
-
Object
- Object
- GMSEC::ConfigFile
- Extended by:
- API
- Defined in:
- lib/gmsec/config_file.rb
Instance Method Summary collapse
- #from_xml(str) ⇒ Object
- #get_config(config_name) ⇒ Object
- #get_message(message_name, message: GMSEC::Message.new) ⇒ Object
- #get_subscription(subscription_name) ⇒ Object
-
#initialize(filename) ⇒ ConfigFile
constructor
A new instance of ConfigFile.
- #to_xml ⇒ Object
Methods included from API
Constructor Details
#initialize(filename) ⇒ ConfigFile
Returns a new instance of ConfigFile.
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/gmsec/config_file.rb', line 9 def initialize(filename) case when filename.nil? raise RuntimeError.new("Unable to create ConfigFile instance: filename not provided") when !File.exist?(filename.to_s) raise RuntimeError.new("Unable to create ConfigFile instance: '#{filename}' does not exist") end initialize_native_object do |pointer| gmsec_CreateConfigFile(pointer, filename, status) end gmsec_LoadConfigFile(self, status) if status.is_error? raise RuntimeError.new("Error reading config file: #{status}") end end |
Instance Method Details
#from_xml(str) ⇒ Object
34 35 36 |
# File 'lib/gmsec/config_file.rb', line 34 def from_xml(str) gmsec_FromXMLConfigFile(self, str, status) end |
#get_config(config_name) ⇒ Object
38 39 40 41 42 |
# File 'lib/gmsec/config_file.rb', line 38 def get_config(config_name) GMSEC::Config.new.tap do |config| gmsec_LookupConfigFileConfig(self, config_name, config, status) end end |
#get_message(message_name, message: GMSEC::Message.new) ⇒ Object
44 45 46 47 48 |
# File 'lib/gmsec/config_file.rb', line 44 def (, message: GMSEC::Message.new) .tap do || gmsec_LookupConfigFileMessage(self, , , status) end end |
#get_subscription(subscription_name) ⇒ Object
50 51 52 53 54 |
# File 'lib/gmsec/config_file.rb', line 50 def get_subscription(subscription_name) with_string_pointer do |pointer| gmsec_LookupConfigFileSubscription(self, subscription_name, pointer, status) end end |
#to_xml ⇒ Object
28 29 30 31 32 |
# File 'lib/gmsec/config_file.rb', line 28 def to_xml with_string_pointer do |pointer| gmsec_ToXMLConfigFile(self, pointer, status) end end |