Class: EivuFingerprinterAcoustid::Objects::ResultSet
- Inherits:
-
Object
- Object
- EivuFingerprinterAcoustid::Objects::ResultSet
- Defined in:
- lib/eivu_fingerprinter_acoustid/objects/result_set.rb
Constant Summary collapse
- OK_STATUS =
'ok'
Instance Attribute Summary collapse
-
#results ⇒ Object
readonly
Returns the value of attribute results.
-
#status ⇒ Object
readonly
Returns the value of attribute status.
Instance Method Summary collapse
- #best_match(duration:, release_group_name: nil) ⇒ Object
-
#initialize(results:, status:) ⇒ ResultSet
constructor
A new instance of ResultSet.
- #ok? ⇒ Boolean
Constructor Details
#initialize(results:, status:) ⇒ ResultSet
Returns a new instance of ResultSet.
11 12 13 14 |
# File 'lib/eivu_fingerprinter_acoustid/objects/result_set.rb', line 11 def initialize(results:, status:) @results = results.collect { |r| EivuFingerprinterAcoustid::Objects::Result.new(**r) } @status = status end |
Instance Attribute Details
#results ⇒ Object (readonly)
Returns the value of attribute results.
7 8 9 |
# File 'lib/eivu_fingerprinter_acoustid/objects/result_set.rb', line 7 def results @results end |
#status ⇒ Object (readonly)
Returns the value of attribute status.
7 8 9 |
# File 'lib/eivu_fingerprinter_acoustid/objects/result_set.rb', line 7 def status @status end |
Instance Method Details
#best_match(duration:, release_group_name: nil) ⇒ Object
16 17 18 19 20 21 22 23 |
# File 'lib/eivu_fingerprinter_acoustid/objects/result_set.rb', line 16 def best_match(duration:, release_group_name: nil) raise(ArgumentError, 'ResultSet did not return OK') unless ok? # generate array of matches matches = results.collect {|r| r.generate_match(duration: duration, release_group_name: release_group_name) } # prune nil results and return highest scoring match matches.compact.max end |
#ok? ⇒ Boolean
25 26 27 |
# File 'lib/eivu_fingerprinter_acoustid/objects/result_set.rb', line 25 def ok? @status == OK_STATUS end |