Class: Mindee::V2::Parsing::Search::SearchModels

Inherits:
Array
  • Object
show all
Defined in:
lib/mindee/v2/parsing/search/search_models.rb

Overview

Array of search models.

Instance Method Summary collapse

Constructor Details

#initialize(prediction) ⇒ SearchModels

Returns a new instance of SearchModels.



9
10
11
# File 'lib/mindee/v2/parsing/search/search_models.rb', line 9

def initialize(prediction)
  super(prediction.map { |entry| SearchModel.new(entry) })
end

Instance Method Details

#to_sString

Default string representation.

Returns:

  • (String)


15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/mindee/v2/parsing/search/search_models.rb', line 15

def to_s
  return "\n" if empty?

  lines = flat_map do |model|
    [
      "* :Name: #{model.name}",
      "  :ID: #{model.id}",
      "  :Model Type: #{model.model_type}",
    ]
  end

  # Joins all lines with a newline and appends a final newline
  # to perfectly match the C# StringBuilder output.
  "#{lines.join("\n")}\n"
end