Class: EivuFingerprinterAcoustid::Objects::Result
- Defined in:
- lib/eivu_fingerprinter_acoustid/objects/result.rb
Constant Summary collapse
- DURATION_ACCEPTANCE_RANGE =
15
Instance Attribute Summary collapse
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#recordings ⇒ Object
readonly
Returns the value of attribute recordings.
-
#score ⇒ Object
readonly
Returns the value of attribute score.
Instance Method Summary collapse
- #generate_match(duration:, release_group_name: nil) ⇒ Object
-
#initialize(id:, recordings: [], score: nil) ⇒ Result
constructor
A new instance of Result.
- #no_recordings? ⇒ Boolean
- #recordings? ⇒ Boolean
Methods inherited from BaseClass
Constructor Details
#initialize(id:, recordings: [], score: nil) ⇒ Result
Returns a new instance of Result.
11 12 13 14 15 |
# File 'lib/eivu_fingerprinter_acoustid/objects/result.rb', line 11 def initialize(id:, recordings: [], score: nil) @id = id @recordings = recordings.collect { |r| EivuFingerprinterAcoustid::Objects::Recording.new(**r) } @score = score end |
Instance Attribute Details
#id ⇒ Object (readonly)
Returns the value of attribute id.
9 10 11 |
# File 'lib/eivu_fingerprinter_acoustid/objects/result.rb', line 9 def id @id end |
#recordings ⇒ Object (readonly)
Returns the value of attribute recordings.
9 10 11 |
# File 'lib/eivu_fingerprinter_acoustid/objects/result.rb', line 9 def recordings @recordings end |
#score ⇒ Object (readonly)
Returns the value of attribute score.
9 10 11 |
# File 'lib/eivu_fingerprinter_acoustid/objects/result.rb', line 9 def score @score end |
Instance Method Details
#generate_match(duration:, release_group_name: nil) ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/eivu_fingerprinter_acoustid/objects/result.rb', line 17 def generate_match(duration:, release_group_name: nil) filtered_recordings = filter_empty_recordings(recordings) if release_group_name.present? filter_recordings_via_release_group_name(filtered_recordings, release_group_name) elsif duration.present? filter_recordings_via_duration(filtered_recordings, duration) else nil end end |
#no_recordings? ⇒ Boolean
33 34 35 |
# File 'lib/eivu_fingerprinter_acoustid/objects/result.rb', line 33 def no_recordings? @no_recordings ||= !recordings? end |
#recordings? ⇒ Boolean
29 30 31 |
# File 'lib/eivu_fingerprinter_acoustid/objects/result.rb', line 29 def recordings? @has_recordings ||= recordings.present? end |