Class: EivuFingerprinterAcoustid::Objects::Recording

Inherits:
BaseClass
  • Object
show all
Defined in:
lib/eivu_fingerprinter_acoustid/objects/recording.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from BaseClass

#==, #hash, #state

Constructor Details

#initialize(id:, title: nil, artists: [], release_groups: [], releasegroups: [], duration: nil) ⇒ Recording

Returns a new instance of Recording.



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/eivu_fingerprinter_acoustid/objects/recording.rb', line 10

def initialize(id:, title: nil, artists: [], release_groups: [], releasegroups: [], duration: nil)
  if release_groups.present? && releasegroups.present?
    raise ArgumentError, 'can not pass in both release_groups AND releasegroups to constructor'
  end

  @id             = id
  @duration       = duration
  @title          = title
  @artists        = instantiate_artists(artists)
  @releasegroups  = releasegroups.collect do |rg|
    case rg.class.name
    when 'Hash'
      EivuFingerprinterAcoustid::Objects::ReleaseGroup.new(**rg)
    when 'EivuFingerprinterAcoustid::Objects::ReleaseGroup'
      rg
    else
      raise ArgumentError, "Mismatched Type: #{rg.class} passed to create release group"
    end
  end
end

Instance Attribute Details

#artistsObject (readonly)

Returns the value of attribute artists.



8
9
10
# File 'lib/eivu_fingerprinter_acoustid/objects/recording.rb', line 8

def artists
  @artists
end

#durationObject (readonly)

Returns the value of attribute duration.



8
9
10
# File 'lib/eivu_fingerprinter_acoustid/objects/recording.rb', line 8

def duration
  @duration
end

#idObject (readonly)

Returns the value of attribute id.



8
9
10
# File 'lib/eivu_fingerprinter_acoustid/objects/recording.rb', line 8

def id
  @id
end

#releasegroupsObject (readonly) Also known as: release_groups

Returns the value of attribute releasegroups.



8
9
10
# File 'lib/eivu_fingerprinter_acoustid/objects/recording.rb', line 8

def releasegroups
  @releasegroups
end

#titleObject (readonly)

Returns the value of attribute title.



8
9
10
# File 'lib/eivu_fingerprinter_acoustid/objects/recording.rb', line 8

def title
  @title
end

Instance Method Details

#shallow_cloneObject

will delete before completion



32
33
34
# File 'lib/eivu_fingerprinter_acoustid/objects/recording.rb', line 32

def shallow_clone
  EivuFingerprinterAcoustid::Objects::Recording.new(id: id, title: title, artists: artists, releasegroups: [], duration: duration)
end