Class: DatagroutConduit::DiscoverResult

Inherits:
Struct
  • Object
show all
Defined in:
lib/datagrout_conduit/types.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Attribute Details

#queryObject

Returns the value of attribute query

Returns:

  • (Object)

    the current value of query



164
165
166
# File 'lib/datagrout_conduit/types.rb', line 164

def query
  @query
end

#toolsObject

Returns the value of attribute tools

Returns:

  • (Object)

    the current value of tools



164
165
166
# File 'lib/datagrout_conduit/types.rb', line 164

def tools
  @tools
end

#totalObject

Returns the value of attribute total

Returns:

  • (Object)

    the current value of total



164
165
166
# File 'lib/datagrout_conduit/types.rb', line 164

def total
  @total
end

Class Method Details

.from_hash(hash) ⇒ Object



165
166
167
168
169
170
171
172
173
174
175
# File 'lib/datagrout_conduit/types.rb', line 165

def self.from_hash(hash)
  hash = hash.transform_keys(&:to_s)
  # DG returns "results" (not "tools") and "goal_used" (not "query")
  tools_raw = hash["results"] || hash["tools"] || []
  tools = tools_raw.map { |t| DiscoveredTool.from_hash(t) }
  new(
    tools: tools,
    query: hash["goal_used"] || hash["query"],
    total: hash["total"] || tools.size
  )
end