<commit_before>require 'httparty'

module Vigor
  class Client
    include HTTParty
    # debug_output $stderr

    def initialize(api_key, region = "na")
      self.class.default_params :api_key => api_key
      self.class.base_uri "http://prod.api.pvp.net/api/lol/#{region}/v1.1"
    end

    def summoner(lookup_value)
      if lookup_value.is_a? String
        return Summoner.new(self.class.get("/summoner/by-name/" + lookup_value.gsub(/\s+/, "")))
      else
        return Summoner.new(self.class.get("/summoner/" + lookup_value.to_s))
      end
    end
  end

  class Summoner
    attr_accessor :id, :name, :profile_icon_id, :level, :revision_date

    def initialize(data)
      @id = data["id"]
      @name = data["name"]
      @profile_icon_id = data["profileIconId"]
      @level = data["summonerLevel"]
      @revision_date = DateTime.strptime(data["revisionDate"].to_s,'%s')
    end

    def mastery_pages
      @mastery_pages ||= Client.get("/summoner/" + @id.to_s + "/masteries")["pages"].map {|page| MasteryPage.new(page)}
    end

    def rune_pages
      @rune_pages ||= Client.get("/summoner/" + @id.to_s + "/runes")["pages"].map {|page| RunePage.new(page)}
      #Client.get("/summoner/" + @id.to_s + "/runes")["pages"]
    end

    def current_mastery_page
      mastery_pages.find {|page| page.current? }
    end

    def current_rune_page
      rune_pages.find {|page| page.current? }
    end
  end

  class Page
    attr_accessor :name

    def initialize(data)
      @name = data["name"]
      @current = data["current"]
    end

    def current?
      @current
    end
  end

  class MasteryPage < Page
    attr_accessor :talents

    def initialize(data)
      super
      
      return if data["talents"].nil?
      @talents = data["talents"].map {|talent| Talent.new(talent)}
    end
  end

  class Talent
    attr_accessor :id, :rank, :name

    def initialize(data)
      @id = data["id"]
      @rank = data["rank"]
      @name = data["name"]
    end
  end

  class RunePage < Page
    attr_accessor :runes, :id

    def initialize(data)
      super
      @id = data["id"]

      return if data["slots"].nil?
      @runes = data["slots"].map {|slot| Rune.new(slot)}
    end
  end

  class Rune
    attr_accessor :slotId, :runeId, :description, :name, :tier

    def initialize(data)
      rune = data["rune"]

      @slotId = data["runeSlotId"]
      @runeId = rune["id"]
      @description = rune["description"]
      @name = rune["name"]
      @tier = rune["tier"]
    end
  end
end<commit_msg>Change parameters to snake_case for consistency.<commit_after>require 'httparty'

module Vigor
  class Client
    include HTTParty
    # debug_output $stderr

    def initialize(api_key, region = "na")
      self.class.default_params :api_key => api_key
      self.class.base_uri "http://prod.api.pvp.net/api/lol/#{region}/v1.1"
    end

    def summoner(lookup_value)
      if lookup_value.is_a? String
        return Summoner.new(self.class.get("/summoner/by-name/" + lookup_value.gsub(/\s+/, "")))
      else
        return Summoner.new(self.class.get("/summoner/" + lookup_value.to_s))
      end
    end
  end

  class Summoner
    attr_accessor :id, :name, :profile_icon_id, :level, :revision_date

    def initialize(data)
      @id = data["id"]
      @name = data["name"]
      @profile_icon_id = data["profileIconId"]
      @level = data["summonerLevel"]
      @revision_date = DateTime.strptime(data["revisionDate"].to_s,'%s')
    end

    def mastery_pages
      @mastery_pages ||= Client.get("/summoner/" + @id.to_s + "/masteries")["pages"].map {|page| MasteryPage.new(page)}
    end

    def rune_pages
      @rune_pages ||= Client.get("/summoner/" + @id.to_s + "/runes")["pages"].map {|page| RunePage.new(page)}
    end

    def current_mastery_page
      mastery_pages.find {|page| page.current? }
    end

    def current_rune_page
      rune_pages.find {|page| page.current? }
    end
  end

  class Page
    attr_accessor :name

    def initialize(data)
      @name = data["name"]
      @current = data["current"]
    end

    def current?
      @current
    end
  end

  class MasteryPage < Page
    attr_accessor :talents

    def initialize(data)
      super

      return if data["talents"].nil?
      @talents = data["talents"].map {|talent| Talent.new(talent)}
    end
  end

  class Talent
    attr_accessor :id, :rank, :name

    def initialize(data)
      @id = data["id"]
      @rank = data["rank"]
      @name = data["name"]
    end
  end

  class RunePage < Page
    attr_accessor :runes, :id

    def initialize(data)
      super
      @id = data["id"]

      return if data["slots"].nil?
      @runes = data["slots"].map {|slot| Rune.new(slot)}
    end
  end

  class Rune
    attr_accessor :slot_id, :rune_id, :description, :name, :tier

    def initialize(data)
      rune = data["rune"]

      @slot_id = data["runeSlotId"]
      @rune_id = rune["id"]
      @description = rune["description"]
      @name = rune["name"]
      @tier = rune["tier"]
    end
  end
end
{'fraction_non_alphanumeric': 0.1408674890569041, 'fraction_numerical': 0.0007958615200955034, 'mean_word_length': 2.6506899055918662, 'pattern_counts': {'":': 0, '<': 7, '<?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': '561423', 'n_tokens_mistral': 1811, 'n_tokens_neox': 1757, 'n_words': 369}