Class: Lutaml::Xsd::BatchTypeQuery

Inherits:
Object
  • Object
show all
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

Instance Method Summary collapse

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

#repositoryObject (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

Parameters:

  • qualified_names (Array<String>)

    Array of qualified type names

Returns:



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

Parameters:

  • file_path (String)

    Path to file containing qualified names

Returns:



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_stdinArray<BatchQueryResult>

Execute from stdin

Returns:



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