Method: IPXACT::Parser::ComponentData.select_component
- Defined in:
- lib/ipxact/parser/component_data_parser.rb
.select_component(component_id, component_docs) ⇒ Component
Selects from the component_docs the component that corresponds to the component_id
.
114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 |
# File 'lib/ipxact/parser/component_data_parser.rb', line 114 def self.select_component(component_id, component_docs) if component_id.kind_of?(Array) && component_id.size == 2 # A version must have been specified raise ArgumentError, "Component '#{component_id}' could not be found!" \ unless component_docs.has_key? component_id component_name, component_version = component_id else component_name = component_id component_version = component_docs.keys.select{|name, version| name == component_name} \ .collect{|name, version| version} \ .sort{|a, b| 1 if IPXACT::Identifier::is_most_recent_version?(a,b) 0 if IPXACT::Identifier::is_same_version?(a,b) -1 }.last end [component_name, component_version] end |