Class: SimpleXmiToECore::MapHelper
- Defined in:
- lib/puppet/vendor/rgen/test/xml_instantiator_test/simple_xmi_to_ecore.rb
Direct Known Subclasses
Instance Method Summary collapse
- #[](key) ⇒ Object
-
#initialize(keyMethod, valueMethod, elements) ⇒ MapHelper
constructor
A new instance of MapHelper.
Constructor Details
#initialize(keyMethod, valueMethod, elements) ⇒ MapHelper
Returns a new instance of MapHelper.
10 11 12 |
# File 'lib/puppet/vendor/rgen/test/xml_instantiator_test/simple_xmi_to_ecore.rb', line 10 def initialize(keyMethod,valueMethod,elements) @keyMethod, @valueMethod, @elements = keyMethod, valueMethod, elements end |
Instance Method Details
#[](key) ⇒ Object
13 14 15 16 |
# File 'lib/puppet/vendor/rgen/test/xml_instantiator_test/simple_xmi_to_ecore.rb', line 13 def [](key) return @elements.select{|e| e.send(@keyMethod) == key}.first.send(@valueMethod) rescue NoMethodError nil end |