Class: UR::XMLConfigFile
- Inherits:
-
Object
- Object
- UR::XMLConfigFile
- Defined in:
- lib/conf.rb
Instance Method Summary collapse
- #get_recipe(key) ⇒ Object
-
#initialize(filename) ⇒ XMLConfigFile
constructor
A new instance of XMLConfigFile.
Constructor Details
#initialize(filename) ⇒ XMLConfigFile
Returns a new instance of XMLConfigFile.
6 7 8 9 10 11 12 13 14 |
# File 'lib/conf.rb', line 6 def initialize(filename) @names = {} @types = {} doc = XML::Smart.open(filename) doc.find('/rtde_config/recipe/@key').each do |key| @names[key.value] = doc.find("/rtde_config/recipe[@key='#{key}']/field/@name").map {|x| x.to_s } @types[key.value] = doc.find("/rtde_config/recipe[@key='#{key}']/field/@type").map {|x| x.to_s } end end |
Instance Method Details
#get_recipe(key) ⇒ Object
16 17 18 |
# File 'lib/conf.rb', line 16 def get_recipe(key) return @names[key], @types[key] if @types.include?(key) && @names.include?(key) end |