Class: Lutaml::Xsd::BatchTypeQuery
- Inherits:
-
Object
- Object
- Lutaml::Xsd::BatchTypeQuery
- Defined in:
- lib/lutaml/xsd/batch_type_query.rb
Overview
Executes batch type queries Single responsibility: process multiple type lookups efficiently
Instance Attribute Summary collapse
-
#repository ⇒ Object
readonly
Returns the value of attribute repository.
Instance Method Summary collapse
-
#execute(qualified_names) ⇒ Array<BatchQueryResult>
Execute batch query from array of qualified names.
-
#execute_from_file(file_path) ⇒ Array<BatchQueryResult>
Execute from file.
-
#execute_from_stdin ⇒ Array<BatchQueryResult>
Execute from stdin.
-
#initialize(repository) ⇒ BatchTypeQuery
constructor
A new instance of BatchTypeQuery.
Constructor Details
#initialize(repository) ⇒ BatchTypeQuery
Returns a new instance of BatchTypeQuery.
10 11 12 |
# File 'lib/lutaml/xsd/batch_type_query.rb', line 10 def initialize(repository) @repository = repository end |
Instance Attribute Details
#repository ⇒ Object (readonly)
Returns the value of attribute repository.
8 9 10 |
# File 'lib/lutaml/xsd/batch_type_query.rb', line 8 def repository @repository end |
Instance Method Details
#execute(qualified_names) ⇒ Array<BatchQueryResult>
Execute batch query from array of qualified names
17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/lutaml/xsd/batch_type_query.rb', line 17 def execute(qualified_names) qualified_names.map do |qname| result = @repository.find_type(qname.strip) BatchQueryResult.new( query: qname, resolved: result.resolved?, result: result, ) end end |
#execute_from_file(file_path) ⇒ Array<BatchQueryResult>
Execute from file
32 33 34 35 |
# File 'lib/lutaml/xsd/batch_type_query.rb', line 32 def execute_from_file(file_path) names = File.readlines(file_path).map(&:strip).reject(&:empty?) execute(names) end |
#execute_from_stdin ⇒ Array<BatchQueryResult>
Execute from stdin
39 40 41 42 |
# File 'lib/lutaml/xsd/batch_type_query.rb', line 39 def execute_from_stdin names = $stdin.readlines.map(&:strip).reject(&:empty?) execute(names) end |