class MetalArchives::Band
Represents an band (person or group)
Attributes
Returns Array of String
- Raises
-
MetalArchives::Errors::InvalidIDErrorwhen no or invalid id -
MetalArchives::Errors::APIErrorwhen receiving a status code >= 400 (except 404)
Returns raw HTML String
- Raises
-
MetalArchives::Errors::InvalidIDErrorwhen no or invalid id -
MetalArchives::Errors::APIErrorwhen receiving a status code >= 400 (except 404)
Returns ISO3166::Country
- Raises
-
MetalArchives::Errors::InvalidIDErrorwhen no or invalid id -
MetalArchives::Errors::APIErrorwhen receiving a status code >= 400 (except 404)
Returns Array of Range containing NilDate
- Raises
-
MetalArchives::Errors::InvalidIDErrorwhen no or invalid id -
MetalArchives::Errors::APIErrorwhen receiving a status code >= 400 (except 404)
Returns NilDate
- Raises
-
MetalArchives::Errors::InvalidIDErrorwhen no or invalid id -
MetalArchives::Errors::APIErrorwhen receiving a status code >= 400 (except 404)
Returns Array of String
- Raises
-
MetalArchives::Errors::InvalidIDErrorwhen no or invalid id -
MetalArchives::Errors::APIErrorwhen receiving a status code >= 400 (except 404)
Returns Integer
Returns boolean
- Raises
-
MetalArchives::Errors::InvalidIDErrorwhen no or invalid id -
MetalArchives::Errors::APIErrorwhen receiving a status code >= 400 (except 404)
Returns Label
- Raises
-
MetalArchives::Errors::InvalidIDErrorwhen no or invalid id -
MetalArchives::Errors::APIErrorwhen receiving a status code >= 400 (except 404)
Returns Array of Hash containing the following keys
- Raises
-
MetalArchives::Errors::InvalidIDErrorwhen no or invalid id -
MetalArchives::Errors::APIErrorwhen receiving a status code >= 400 (except 404)
links-
:url:String -
:type:Symbol, either:officialor:merchandise -
:title:String
-
Returns String
- Raises
-
MetalArchives::Errors::InvalidIDErrorwhen no or invalid id -
MetalArchives::Errors::APIErrorwhen receiving a status code >= 400 (except 404)
Returns URI (rewritten if config option was enabled)
- Raises
-
MetalArchives::Errors::InvalidIDErrorwhen no or invalid id -
MetalArchives::Errors::APIErrorwhen receiving a status code >= 400 (except 404)
Returns Array of String
- Raises
-
MetalArchives::Errors::InvalidIDErrorwhen no or invalid id -
MetalArchives::Errors::APIErrorwhen receiving a status code >= 400 (except 404)
Returns String
- Raises
-
MetalArchives::Errors::InvalidIDErrorwhen no or invalid id -
MetalArchives::Errors::APIErrorwhen receiving a status code >= 400 (except 404)
Returns URI (rewritten if config option was enabled)
- Raises
-
MetalArchives::Errors::InvalidIDErrorwhen no or invalid id -
MetalArchives::Errors::APIErrorwhen receiving a status code >= 400 (except 404)
Returns Array of Release
- Raises
-
MetalArchives::Errors::InvalidIDErrorwhen no or invalid id -
MetalArchives::Errors::APIErrorwhen receiving a status code >= 400 (except 404)
Returns Array of Hash containing the following keys
- Raises
-
MetalArchives::Errors::InvalidIDErrorwhen no or invalid id -
MetalArchives::Errors::APIErrorwhen receiving a status code >= 400 (except 404)
similar-
:band:Band -
:score:Integer
-
Returns :active, :split_up, :on_hold, :unknown, :changed_name or :disputed
- Raises
-
MetalArchives::Errors::InvalidIDErrorwhen no or invalid id -
MetalArchives::Errors::APIErrorwhen receiving a status code >= 400 (except 404)
Protected Class Methods
Get all bands
Returns Collection of Band
- Raises
-
MetalArchives::Errors::APIErrorwhen receiving a status code >= 400 -
MetalArchives::Errors::ParserErrorwhen parsing failed. Please report this error.
# File lib/metal_archives/models/band.rb, line 454 def all search_by({}) end
Find by ID
Returns Band, even when ID is invalid (because the data is lazily fetched)
id-
Integer
# File lib/metal_archives/models/band.rb, line 269 def find(id) return cache[id] if cache.include? id Band.new id: id end
Find by ID (no lazy loading)
Returns Band
- Raises
-
MetalArchives::Errors::InvalidIDErrorwhen no or invalid id -
MetalArchives::Errors::APIErrorwhen receiving a status code >= 400 (except 404) -
MetalArchives::Errors::ParserErrorwhen parsing failed. Please report this error.
id-
Integer
# File lib/metal_archives/models/band.rb, line 288 def find!(id) obj = find id obj.load! if obj && !obj.loaded? obj end
Find by attributes
Refer to MA’s FAQ for search tips.
Returns Band or nil when no results
- Raises
-
MetalArchives::Errors::APIErrorwhen receiving a status code >= 400 -
MetalArchives::Errors::ParserErrorwhen parsing failed. Please report this error.
query-
Hash containing one or more of the following keys:
-
:name:String -
:exact:Boolean -
:genre:String -
:country:ISO3166::Country -
:comment:String -
:status: seeBand.status -
:lyrical_themes:String -
:location:String -
:label:Label -
:independent: boolean
-
# File lib/metal_archives/models/band.rb, line 320 def find_by(query) url = "#{MetalArchives.config.default_endpoint}search/ajax-advanced/searching/bands" params = Parsers::Band.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.first).xpath("//a/@href").first.value.delete('\\').split("/").last.gsub(/\D/, "").to_i find id end
Find by attributes (no lazy loading)
Refer to MA’s FAQ for search tips.
Returns Band or nil when no results
- Raises
-
MetalArchives::Errors::APIErrorwhen receiving a status code >= 400 -
MetalArchives::Errors::ParserErrorwhen parsing failed. Please report this error.
query-
Hash containing one or more of the following keys:
-
:name:String -
:exact:Boolean -
:genre:String -
:country:ISO3166::Country -
:comment:String -
:status: seeBand.status -
:lyrical_themes:String -
:location:String -
:label:Label -
:independent: boolean
-
# File lib/metal_archives/models/band.rb, line 360 def find_by!(query) obj = find_by query obj.load! if obj && !obj.loaded? obj end
Search by name, resolves to Band.search_by (:name => name)
Refer to MA’s FAQ for search tips.
Returns (possibly empty) Array of Band
- Raises
-
MetalArchives::Errors::APIErrorwhen receiving a status code >= 400 -
MetalArchives::Errors::ArgumentErrorwhennameisn't aString
name-
String
# File lib/metal_archives/models/band.rb, line 439 def search(name) raise MetalArchives::Errors::ArgumentError unless name.is_a? String search_by name: name end
Search by attributes
Refer to MA’s FAQ for search tips.
Returns Collection of Band
- Raises
-
MetalArchives::Errors::APIErrorwhen receiving a status code >= 400 -
MetalArchives::Errors::ParserErrorwhen parsing failed. Please report this error.
query-
Hash containing one or more of the following keys:
-
:name:String -
:exact:Boolean -
:genre:String -
:country:ISO3166::Country -
:comment:String -
:status: seeBand.status -
:lyrical_themes:String -
:location:String -
:label:Label -
:independent: boolean
-
# File lib/metal_archives/models/band.rb, line 392 def search_by(query) url = "#{MetalArchives.config.default_endpoint}search/ajax-advanced/searching/bands" params = Parsers::Band.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 Band 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 << Band.find(id) end @start += 200 objects end end MetalArchives::Collection.new l end