Sha256: e29d40db4fd5ec7b5931b69ebc4b4ab9045e6aba2d639bdfcf7988e799c8f271

Contents?: true

Size: 1.02 KB

Versions: 1

Compression:

Stored size: 1.02 KB

Contents

module Smite
  class Player < Smite::Object
    attr_reader :player_name

    def initialize(player_name)
      @player_name  = player_name
      super(Smite::Game.client.player(player_name)[0])
    end

    def friends
      return @friends unless @friends.nil?

      @friends = Smite::Game.client.friends(player_name)
      @friends = @friends.reject { |f| f['name'].empty? }
      @friends.map!(&Friend.method(:new))
    end

    def god_ranks
      return @ranks unless @ranks.nil?

      @ranks = Smite::Game.client.god_ranks(player_name)
      @ranks.map!(&GodRank.method(:new))
    end

    def match_history
      return @history unless @history.nil?

      @history = Smite::Game.client.match_history(player_name)
      @history.map!(&RecentMatch.method(:new))
    end

    def achievements
      return @achievements unless @achievements.nil?

      achievements  = Smite::Game.client.achievements(id)
      @achievements = Achievements.new(achievements)
    end

    def inspect
      "#<Smite::Player '#{name}'>"
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
smite_ruby-1.4.5 lib/smite/player.rb