Class: Rafflesia::CombinedSearchData

Inherits:
Types::BaseModel
  • Object
show all
Defined in:
lib/rafflesia/search/combined_search_data.rb

Constant Summary collapse

HASH_ATTRS =
{
  backend: :backend,
  domain: :domain,
  failed_source_count: :failed_source_count,
  hit_count: :hit_count,
  hits: :hits,
  max_hits: :max_hits,
  partial: :partial,
  promotion_candidates: :promotion_candidates,
  raw_hit_count: :raw_hit_count,
  requested_source_count: :requested_source_count,
  sources: :sources,
  succeeded_source_count: :succeeded_source_count
}.freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(json) ⇒ CombinedSearchData

Returns a new instance of CombinedSearchData.



37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# File 'lib/rafflesia/search/combined_search_data.rb', line 37

def initialize(json)
  super()
  hash = self.class.normalize(json)
  @backend = hash[:backend]
  @domain = hash[:domain]
  @failed_source_count = hash[:failed_source_count]
  @hit_count = hash[:hit_count]
  @hits = (hash[:hits] || []).map { |item| item ? Rafflesia::CombinedSearchHit.new(item) : nil }
  @max_hits = hash[:max_hits]
  @partial = hash[:partial]
  @promotion_candidates = (hash[:promotion_candidates] || []).map { |item| item ? Rafflesia::CombinedSearchPromotionCandidate.new(item) : nil }
  @raw_hit_count = hash[:raw_hit_count]
  @requested_source_count = hash[:requested_source_count]
  @sources = (hash[:sources] || []).map { |item| item ? Rafflesia::CombinedSearchSourceStatus.new(item) : nil }
  @succeeded_source_count = hash[:succeeded_source_count]
end

Instance Attribute Details

#backendObject

Returns the value of attribute backend.



23
24
25
# File 'lib/rafflesia/search/combined_search_data.rb', line 23

def backend
  @backend
end

#domainObject

Returns the value of attribute domain.



23
24
25
# File 'lib/rafflesia/search/combined_search_data.rb', line 23

def domain
  @domain
end

#failed_source_countObject

Returns the value of attribute failed_source_count.



23
24
25
# File 'lib/rafflesia/search/combined_search_data.rb', line 23

def failed_source_count
  @failed_source_count
end

#hit_countObject

Returns the value of attribute hit_count.



23
24
25
# File 'lib/rafflesia/search/combined_search_data.rb', line 23

def hit_count
  @hit_count
end

#hitsObject

Returns the value of attribute hits.



23
24
25
# File 'lib/rafflesia/search/combined_search_data.rb', line 23

def hits
  @hits
end

#max_hitsObject

Returns the value of attribute max_hits.



23
24
25
# File 'lib/rafflesia/search/combined_search_data.rb', line 23

def max_hits
  @max_hits
end

#partialObject

Returns the value of attribute partial.



23
24
25
# File 'lib/rafflesia/search/combined_search_data.rb', line 23

def partial
  @partial
end

#promotion_candidatesObject

Returns the value of attribute promotion_candidates.



23
24
25
# File 'lib/rafflesia/search/combined_search_data.rb', line 23

def promotion_candidates
  @promotion_candidates
end

#raw_hit_countObject

Returns the value of attribute raw_hit_count.



23
24
25
# File 'lib/rafflesia/search/combined_search_data.rb', line 23

def raw_hit_count
  @raw_hit_count
end

#requested_source_countObject

Returns the value of attribute requested_source_count.



23
24
25
# File 'lib/rafflesia/search/combined_search_data.rb', line 23

def requested_source_count
  @requested_source_count
end

#sourcesObject

Returns the value of attribute sources.



23
24
25
# File 'lib/rafflesia/search/combined_search_data.rb', line 23

def sources
  @sources
end

#succeeded_source_countObject

Returns the value of attribute succeeded_source_count.



23
24
25
# File 'lib/rafflesia/search/combined_search_data.rb', line 23

def succeeded_source_count
  @succeeded_source_count
end