Class: Twingly::Search::Result

Inherits:
Object
  • Object
show all
Defined in:
lib/twingly/search/result.rb

Overview

Represents a result from a Query to the Search API

See Also:

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#incomplete_result=(value) ⇒ Object (writeonly)

Sets the attribute incomplete_result

Parameters:

  • value

    the value to set the attribute incomplete_result to.



17
18
19
# File 'lib/twingly/search/result.rb', line 17

def incomplete_result=(value)
  @incomplete_result = value
end

#number_of_matches_returnedInteger

number of Posts the Query returned.

Returns:

  • (Integer)

    the current value of number_of_matches_returned



14
15
16
# File 'lib/twingly/search/result.rb', line 14

def number_of_matches_returned
  @number_of_matches_returned
end

#number_of_matches_totalInteger

total number of Posts the Query matched.

Returns:

  • (Integer)

    the current value of number_of_matches_total



14
15
16
# File 'lib/twingly/search/result.rb', line 14

def number_of_matches_total
  @number_of_matches_total
end

#seconds_elapsedInteger

number of seconds it took to execute the Query.

Returns:

  • (Integer)

    the current value of seconds_elapsed



14
15
16
# File 'lib/twingly/search/result.rb', line 14

def seconds_elapsed
  @seconds_elapsed
end

Instance Method Details

#all_results_returned?true, false

Returns:

  • (true)

    if this result includes all Posts that matched the Query.

  • (false)

    if there are more Posts to fetch from the API.



35
36
37
# File 'lib/twingly/search/result.rb', line 35

def all_results_returned?
  number_of_matches_returned.to_i == number_of_matches_total.to_i
end

#incomplete?true, false

Returns:

  • (true)

    if one or multiple servers were too slow to respond within the maximum allowed query time.

  • (false)

    if all servers responded within the maximum allowed query time.

See Also:



24
25
26
# File 'lib/twingly/search/result.rb', line 24

def incomplete?
  @incomplete_result
end

#inspectObject



39
40
41
42
43
44
45
46
47
48
49
50
# File 'lib/twingly/search/result.rb', line 39

def inspect
  instance_methods = [
    "posts",
    "number_of_matches_returned=#{self.number_of_matches_returned}",
    "number_of_matches_total=#{self.number_of_matches_total}",
    "seconds_elapsed=#{self.seconds_elapsed}",
    "all_results_returned?=#{self.all_results_returned?}",
    "incomplete?=#{self.incomplete?}",
  ].join(", ")

  sprintf("#<%s:0x%x %s>", self.class.name, __id__, instance_methods)
end

#postsArray<Post>

Returns all posts that matched the Query.

Returns:

  • (Array<Post>)

    all posts that matched the Query.



29
30
31
# File 'lib/twingly/search/result.rb', line 29

def posts
  @posts ||= []
end