Class: FronkinBandcamp::Release

Inherits:
Object
  • Object
show all
Defined in:
lib/fronkin_bandcamp/release.rb

Constant Summary collapse

BARE_CREDITS_NODE_SIZE =
2

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(doc) {|_self| ... } ⇒ Release

Returns a new instance of Release.

Yields:

  • (_self)

Yield Parameters:



12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/fronkin_bandcamp/release.rb', line 12

def initialize(doc)
  @title = doc.css('div#name-section h2.trackTitle').text.strip
  @date = Date.parse(doc.css('div.tralbumData.tralbum-credits meta').attribute('content').value).strftime('%-m/%-d/%Y')
  @description = doc.css('div.tralbumData.tralbum-about').text.strip.gsub(/\r/, "\n")
  @credits = scrape_credits(doc)
  @cover = doc.css('div#tralbumArt a.popupImage').attribute('href').value
  @tracks = scrape_tracks(doc)
  @tags = doc.css('div.tralbumData.tralbum-tags a.tag').map(&:text)
  @release_id = tags.find { |tag| tag.match(/\Annr/) }&.upcase
  @formats = scrape_formats(doc)
  @bandcamp_album_id = doc.css('meta[property="og:video"]').attr("content").value.match(/album=(?<bandcamp_album_id>\d+)/).named_captures['bandcamp_album_id']
  yield self if block_given?
end

Instance Attribute Details

#artist_nameObject

Returns the value of attribute artist_name.



6
7
8
# File 'lib/fronkin_bandcamp/release.rb', line 6

def artist_name
  @artist_name
end

#bandcamp_album_idObject (readonly)

Returns the value of attribute bandcamp_album_id.



7
8
9
# File 'lib/fronkin_bandcamp/release.rb', line 7

def bandcamp_album_id
  @bandcamp_album_id
end

#bandcamp_urlObject

Returns the value of attribute bandcamp_url.



6
7
8
# File 'lib/fronkin_bandcamp/release.rb', line 6

def bandcamp_url
  @bandcamp_url
end

#coverObject (readonly)

Returns the value of attribute cover.



7
8
9
# File 'lib/fronkin_bandcamp/release.rb', line 7

def cover
  @cover
end

#creditsObject (readonly)

Returns the value of attribute credits.



7
8
9
# File 'lib/fronkin_bandcamp/release.rb', line 7

def credits
  @credits
end

#dateObject (readonly)

Returns the value of attribute date.



7
8
9
# File 'lib/fronkin_bandcamp/release.rb', line 7

def date
  @date
end

#descriptionObject (readonly)

Returns the value of attribute description.



7
8
9
# File 'lib/fronkin_bandcamp/release.rb', line 7

def description
  @description
end

#formatsObject (readonly)

Returns the value of attribute formats.



7
8
9
# File 'lib/fronkin_bandcamp/release.rb', line 7

def formats
  @formats
end

#release_idObject (readonly)

Returns the value of attribute release_id.



7
8
9
# File 'lib/fronkin_bandcamp/release.rb', line 7

def release_id
  @release_id
end

#tagsObject (readonly)

Returns the value of attribute tags.



7
8
9
# File 'lib/fronkin_bandcamp/release.rb', line 7

def tags
  @tags
end

#titleObject (readonly)

Returns the value of attribute title.



7
8
9
# File 'lib/fronkin_bandcamp/release.rb', line 7

def title
  @title
end

#tracksObject (readonly)

Returns the value of attribute tracks.



7
8
9
# File 'lib/fronkin_bandcamp/release.rb', line 7

def tracks
  @tracks
end