<commit_before>require 'open-uri'
require 'json'
require 'ostruct'
require 'extensions/strings'

module Rhapsody
  API_KEY = "<KEY>"

  class Artist
    attr_accessor :id, :name, :genre

    def initialize(arguments)
      arguments.each do |key, value|
        if key == "genre"
          instance_variable_set("@#{key}", Genre.new(value))
        else
          instance_variable_set("@#{key}", value)
        end
      end
    end
  end

  class Album
    attr_accessor :id, :name, :artist, :released, :tags, :label, :discs, :genre, :type, :copyright, :images, :tracks

    def initialize(arguments)
      arguments.each do |key, value|
        if key == "artist"
          instance_variable_set("@#{key}", Artist.new(value))
        else
          instance_variable_set("@#{key}", value)
        end
      end
    end

    # not working
    def self.new_releases
      url = "http://api.rhapsody.com/v0/albums/new?apikey=#{API_KEY}"<commit_msg>album class can handle track genre type image objects as classes<commit_after>require 'open-uri'
require 'json'
require 'ostruct'
require 'extensions/strings'

module Rhapsody
  API_KEY = "<KEY>"

  class Artist
    attr_accessor :id, :name, :genre

    def initialize(arguments)
      arguments.each do |key, value|
        if key == "genre"
          instance_variable_set("@#{key}", Genre.new(value))
        else
          instance_variable_set("@#{key}", value)
        end
      end
    end
  end

  class Album
    attr_accessor :id, :name, :artist, :released, :tags, :label, :discs, :genre, :type, :copyright, :images, :tracks

    def initialize(arguments)
      arguments.each do |key, value|
        if key == "artist"
          instance_variable_set("@#{key}", Artist.new(value))
        elsif key == "tracks"
          instance_variable_set("@#{key}", value.map.each {|element| Track.new(element)})
        elsif key == "genre"
          instance_variable_set("@#{key}", Genre.new(value))
        elsif key == "type"
          instance_variable_set("@#{key}", Type.new(value))
        elsif key == "images"
          instance_variable_set("@#{key}", value.map.each {|element| Image.new(element)})
        else
          instance_variable_set("@#{key}", value)
        end
      end
    end

    # not working
    def self.new_releases
      url = "http://api.rhapsody.com/v0/albums/new?apikey=#{API_KEY}"
{'fraction_non_alphanumeric': 0.1386892177589852, 'fraction_numerical': 0.0008456659619450317, 'mean_word_length': 2.7496038034865293, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1495683', 'n_tokens_mistral': 768, 'n_tokens_neox': 758, 'n_words': 181}