elvarg 0.0.5 → 0.0.6

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 67e2cce699cff36e9c3449c7c89db0da859d702a3d464e75f78b491636aa1014
4
- data.tar.gz: b5da4d18227f1233ba51e7605aa5d51dc245e2a7209528aeaa6aaa675efc4911
3
+ metadata.gz: 3118f2f2f8a4592ebe5e1bbd48e54165fc4119344dd395fb05f4418f924a685f
4
+ data.tar.gz: 3b24d648e84bf24139b8667ea5f024b2f2079f355ae6763ad3e131b801a024d9
5
5
  SHA512:
6
- metadata.gz: 59a1de2cd781d6b452c4db7d0497fcd2abc30d6cfa23dd8e1eb0bc3013a15e5cba415d0693c9050652945f910fca00ddb593a8102ba25b8a4e2ea28b48990fda
7
- data.tar.gz: 264f3d2466a0780ddff14fcc53f01449d03ce8a1eba2f7fa4d8b94b992ef957f1c982cab3f79ff1565ec19dcdc89f9e7356e1c60064c7edebb5b0493eadc9fb8
6
+ metadata.gz: 38cb35cd448c88b6adef48f938abb9668cc3aa383cef6cc3b6eb508003edb02b84ef024ddd862d48f9456b1ad740acb9a8e02accc462975b7a136b6a4c004042
7
+ data.tar.gz: d3f00779a83fe02ab7f428bc50af1a4a7806bbc14a183eb2b9bb979d3c71a99eca54b37c7fb1afac0afc4d27f0669749bb4c531e513c779a56ca8ff9eb28ebc7
@@ -8,8 +8,13 @@ module Elvarg #:nodoc:
8
8
  # Represents a Player on the Hiscores
9
9
  class Player
10
10
  include Elvarg::Stats
11
+ # The Player's username
11
12
  attr_reader :username
13
+ # The Hiscore's mode.
14
+ # This can be :default, :ironman, :ultimate, etc.
15
+ # @see Hiscores::MODES for complete list
12
16
  attr_reader :mode
17
+ # A Hash of all Stats available in OldSchool Runescape's Hiscores
13
18
  attr_reader :skills
14
19
 
15
20
  ##
@@ -34,6 +39,58 @@ module Elvarg #:nodoc:
34
39
  parse_data(Hiscores.search_for(username, mode))
35
40
  end
36
41
 
42
+ ##
43
+ # Determines if this Player is/was a member at one point in time.
44
+ #
45
+ # @example The player, "Ruby", has trained member's only skills
46
+ # player = Elvarg::Hiscores::Player.new 'Ruby'
47
+ # player.member? #=> true
48
+ #
49
+ # @note This methods determines member status based on if the Player
50
+ # has trained any member skills.
51
+ # @see free?
52
+ # @return [true] if the Player has trained member's only skills.
53
+ # @return [false] if the Player only trained free-to-play skills.
54
+ def member?
55
+ @skills.each { |_, skill| return true if skill.xp > 0 && skill.member? }
56
+ false
57
+ end
58
+
59
+ ##
60
+ # Determines if this Player is a free-to-play player.
61
+ #
62
+ # @example The player, "Ruby", has trained member's only skills
63
+ # player = Elvarg::Hiscores::Player.new 'Ruby'
64
+ # player.free? #=> false
65
+ #
66
+ # @note This is the inverse of #member?
67
+ # @see member?
68
+ # @return [true] if the Player only trained free-to-play skills.
69
+ # @return [false] if the Player has trained member's only skills.
70
+ def free?
71
+ !member?
72
+ end
73
+
74
+ ##
75
+ # Determines if this Player is a skiller (combat level 3).
76
+ #
77
+ # If a Player has any combat level > 1 (with the exception of 10 hitpoints)
78
+ # that Player is classified as a Skiller.
79
+ #
80
+ # @example The player, "Ruby", is not a skiller
81
+ # player = Elvarg::Hiscores::Player.new 'Ruby'
82
+ # player.skiller? #=> false
83
+ #
84
+ # @return [true]
85
+ # @return [false]
86
+ def skiller?
87
+ @skills.each do |key, skill|
88
+ next if key == :hitpoints && skill.level <= 10
89
+ return false if skill.level > 1 && skill.combat?
90
+ end
91
+ true
92
+ end
93
+
37
94
  private
38
95
 
39
96
  ##
@@ -5,15 +5,24 @@ module Elvarg #:nodoc:
5
5
  ##
6
6
  # Represents a Skill on the Hiscores
7
7
  class Skill < Stats::Skill
8
- # TODO
8
+ # The rank of the Skill the Player has on the Hiscores
9
9
  attr_reader :rank
10
- # TODO
10
+ # The level of the Skill the Player has on the Hiscores
11
11
  attr_reader :level
12
- # TODO
12
+ # The experience of the Skill the Player has on the Hiscores
13
13
  attr_reader :exp
14
14
 
15
15
  ##
16
- # TODO
16
+ # Creates a Hiscores Skill object
17
+ #
18
+ # @see Stats::SKILLS
19
+ # @see Stats::Skill#initialize
20
+ # @param symbol [Symbol] the Symbol of the Skill (required)
21
+ # see Stats::SKILLS for complete list
22
+ # @param id [Integer] the unique id of the Skill (default) 0
23
+ # @param rank [Integer] the Player's rank in this Skill (default) -1
24
+ # @param level [Integer] the Player's level in this Skill (default) 1
25
+ # @param exp [Integer] the Player's experience in this Skill (default) 0
17
26
  def initialize(symbol, id = 0, rank = -1, level = 1, exp = 0)
18
27
  super(symbol, id)
19
28
  @rank = rank
@@ -45,22 +45,22 @@ module Elvarg #:nodoc:
45
45
  # Determines if this Skill is a member's only skill.
46
46
  #
47
47
  # @example Slayer is a member's only skill.
48
- # Elvarg::Stats::Skill.new(:hunter).members? #=> true
48
+ # Elvarg::Stats::Skill.new(:hunter).member? #=> true
49
49
  # @example Runecraft is a free-to-play skill.
50
- # Elvarg::Stats::Skill.new(:runecraft).members? #=> false
50
+ # Elvarg::Stats::Skill.new(:runecraft).member? #=> false
51
51
  # @return [true] if this Skill is a member's only skill.
52
52
  # @return [false] if this Skill is free-to-play.
53
- def members?
53
+ def member?
54
54
  MEMBER_SKILLS.include? @symbol
55
55
  end
56
56
 
57
57
  ##
58
58
  # Determines if this Skill is a free-to-play skill.
59
59
  #
60
- # @note This is the inverse of `members?`
61
- # @see members?
60
+ # @note This is the inverse of #member?
61
+ # @see member?
62
62
  def free?
63
- !members?
63
+ !member?
64
64
  end
65
65
 
66
66
  ##
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: elvarg
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.5
4
+ version: 0.0.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Marcello A. Sabino
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-12-27 00:00:00.000000000 Z
11
+ date: 2018-12-29 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: A Ruby Gem that provides useful methods for OldSchool RuneScape related
14
14
  applications.