class MetalArchives::Release

Represents a release

Attributes

date_released[R]

Returns NilDate

Raises
format[R]

Returns :cd, :cassette, :vinyl, :vhs, :dvd, :digital, :blu_ray, :other, :unknown

Raises
id[R]

Returns Integer

limitation[R]

Returns Integer

Raises
notes[R]

Returns raw HTML String

Raises
title[R]

Returns String

Raises
type[R]

Returns :full_length, :live, :demo, :single, :ep, :video, :boxed_set, :split, :compilation, :split_video, :collaboration

Raises

Protected Class Methods

all() click to toggle source

Get all releases

Returns Collection of Release

Raises
# File lib/metal_archives/models/release.rb, line 350
def all
  search ""
end
find(id) click to toggle source

Find by ID

Returns Release, even when ID is invalid (because the data is lazily fetched)

id

Integer

# File lib/metal_archives/models/release.rb, line 144
def find(id)
  return cache[id] if cache.include? id

  Release.new id: id
end
find!(id) click to toggle source

Find by ID (no lazy loading)

Returns Release

Raises
id

Integer

# File lib/metal_archives/models/release.rb, line 163
def find!(id)
  obj = find id
  obj.load! if obj && !obj.loaded?

  obj
end
find_by(query) click to toggle source

Find by attributes

Refer to MA’s FAQ for search tips.

Returns Release or nil when no results

Raises
query

Hash containing one or more of the following keys:

  • :band_name: String

  • :title: String

  • :from_year: Integer

  • :from_month: Integer

  • :to_year: Integer

  • :to_month: Integer

  • :country: ISO3166::Country or Array of ISO3166::Country

  • :location: String

  • :label_name: String

  • :indie: Boolean

  • :catalog_id: String

  • :identifier: String, identifier (barcode, matrix, etc.)

  • :recording_info: String, recording information (studio, city, etc.)

  • :version_description: String, version description (country, digipak, etc.)

  • :notes: String

  • :genre: String

  • :types: Array of Symbol, see Release.type

  • :formats: Array of Symbol, see Release.format

# File lib/metal_archives/models/release.rb, line 202
def find_by(query)
  url = "#{MetalArchives.config.default_endpoint}search/ajax-advanced/searching/albums"
  params = Parsers::Release.map_params query

  response = HTTPClient.get url, params
  json = JSON.parse response.body

  return nil if json["aaData"].empty?

  data = json["aaData"].first
  id = Nokogiri::HTML(data[1]).xpath("//a/@href").first.value.delete('\\').split("/").last.gsub(/\D/, "").to_i

  find id
end
find_by!(query) click to toggle source

Find by attributes (no lazy loading)

Refer to MA’s FAQ for search tips.

Returns Release or nil when no results

Raises
query

Hash containing one or more of the following keys:

  • :band_name: String

  • :title: String

  • :from_year: Integer

  • :from_month: Integer

  • :to_year: Integer

  • :to_month: Integer

  • :country: ISO3166::Country or Array of ISO3166::Country

  • :location: String

  • :label_name: String

  • :indie: Boolean

  • :catalog_id: String

  • :identifier: String, identifier (barcode, matrix, etc.)

  • :recording_info: String, recording information (studio, city, etc.)

  • :version_description: String, version description (country, digipak, etc.)

  • :notes: String

  • :genre: String

  • :types: Array of Symbol, see Release.type

  • :formats: Array of Symbol, see Release.format

# File lib/metal_archives/models/release.rb, line 249
def find_by!(query)
  obj = find_by query
  obj.load! if obj && !obj.loaded?

  obj
end
search_by(query) click to toggle source

Search by attributes

Refer to MA’s FAQ for search tips.

Returns Collection of Release

Raises
query

Hash containing one or more of the following keys:

  • :band_name: String

  • :title: String

  • :from_year: Integer

  • :from_month: Integer

  • :to_year: Integer

  • :to_month: Integer

  • :country: ISO3166::Country or Array of ISO3166::Country

  • :location: String

  • :label_name: String

  • :indie: Boolean

  • :catalog_id: String

  • :identifier: String, identifier (barcode, matrix, etc.)

  • :recording_info: String, recording information (studio, city, etc.)

  • :version_description: String, version description (country, digipak, etc.)

  • :notes: String

  • :genre: String

  • :types: Array of Symbol, see Release.type

  • :formats: Array of Symbol, see Release.format

# File lib/metal_archives/models/release.rb, line 288
def search_by(query)
  url = "#{MetalArchives.config.default_endpoint}search/ajax-advanced/searching/albums"

  params = Parsers::Release.map_params query

  l = lambda do
    @start ||= 0

    if @max_items && @start >= @max_items
      []
    else
      response = HTTPClient.get url, params.merge(iDisplayStart: @start)
      json = JSON.parse response.body

      @max_items = json["iTotalRecords"]

      objects = []

      json["aaData"].each do |data|
        # Create Release object for every ID in the results list
        id = Nokogiri::HTML(data.first).xpath("//a/@href").first.value.delete('\\').split("/").last.gsub(/\D/, "").to_i
        objects << Release.find(id)
      end

      @start += 200

      objects
    end
  end

  MetalArchives::Collection.new l
end

Public Instance Methods

catalog_id() click to toggle source

:attr_reader_: catalog_id

Return String

Raises
# File lib/metal_archives/models/release.rb, line 62
property :catalog_id
version_description() click to toggle source

:attr_reader_: version_description

Return String

Raises
# File lib/metal_archives/models/release.rb, line 73
property :version_description