Class: FronkinBandcamp::Release
- Inherits:
-
Object
- Object
- FronkinBandcamp::Release
- Defined in:
- lib/fronkin_bandcamp/release.rb
Constant Summary collapse
- BARE_CREDITS_NODE_SIZE =
2
Instance Attribute Summary collapse
-
#artist_name ⇒ Object
Returns the value of attribute artist_name.
-
#bandcamp_album_id ⇒ Object
readonly
Returns the value of attribute bandcamp_album_id.
-
#bandcamp_url ⇒ Object
Returns the value of attribute bandcamp_url.
-
#cover ⇒ Object
readonly
Returns the value of attribute cover.
-
#credits ⇒ Object
readonly
Returns the value of attribute credits.
-
#date ⇒ Object
readonly
Returns the value of attribute date.
-
#description ⇒ Object
readonly
Returns the value of attribute description.
-
#formats ⇒ Object
readonly
Returns the value of attribute formats.
-
#release_id ⇒ Object
readonly
Returns the value of attribute release_id.
-
#tags ⇒ Object
readonly
Returns the value of attribute tags.
-
#title ⇒ Object
readonly
Returns the value of attribute title.
-
#tracks ⇒ Object
readonly
Returns the value of attribute tracks.
Instance Method Summary collapse
-
#initialize(doc) {|_self| ... } ⇒ Release
constructor
A new instance of Release.
Constructor Details
#initialize(doc) {|_self| ... } ⇒ Release
Returns a new instance of Release.
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 = .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_name ⇒ Object
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_id ⇒ Object (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_url ⇒ Object
Returns the value of attribute bandcamp_url.
6 7 8 |
# File 'lib/fronkin_bandcamp/release.rb', line 6 def bandcamp_url @bandcamp_url end |
#cover ⇒ Object (readonly)
Returns the value of attribute cover.
7 8 9 |
# File 'lib/fronkin_bandcamp/release.rb', line 7 def cover @cover end |
#credits ⇒ Object (readonly)
Returns the value of attribute credits.
7 8 9 |
# File 'lib/fronkin_bandcamp/release.rb', line 7 def credits @credits end |
#date ⇒ Object (readonly)
Returns the value of attribute date.
7 8 9 |
# File 'lib/fronkin_bandcamp/release.rb', line 7 def date @date end |
#description ⇒ Object (readonly)
Returns the value of attribute description.
7 8 9 |
# File 'lib/fronkin_bandcamp/release.rb', line 7 def description @description end |
#formats ⇒ Object (readonly)
Returns the value of attribute formats.
7 8 9 |
# File 'lib/fronkin_bandcamp/release.rb', line 7 def formats @formats end |
#release_id ⇒ Object (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 |
#tags ⇒ Object (readonly)
Returns the value of attribute tags.
7 8 9 |
# File 'lib/fronkin_bandcamp/release.rb', line 7 def @tags end |
#title ⇒ Object (readonly)
Returns the value of attribute title.
7 8 9 |
# File 'lib/fronkin_bandcamp/release.rb', line 7 def title @title end |
#tracks ⇒ Object (readonly)
Returns the value of attribute tracks.
7 8 9 |
# File 'lib/fronkin_bandcamp/release.rb', line 7 def tracks @tracks end |