Class: Exalted::Stat
- Inherits:
-
Object
- Object
- Exalted::Stat
- Defined in:
- lib/exalted/stat.rb
Overview
A Stat object holds all the information about an Exalted stat. This includes the name, rating, whether it is favoured, or caste and any specialities it might have.
Instance Attribute Summary collapse
-
#caste ⇒ Object
writeonly
set the caste status.
-
#favoured ⇒ Object
writeonly
set the favoured status.
-
#name ⇒ Object
the stat’s name.
-
#rating ⇒ Object
the stat’s rating.
-
#specialities ⇒ Object
specialities the stat has.
Instance Method Summary collapse
- #==(o) ⇒ Object
-
#caste? ⇒ Boolean
Is the stat a caste ability?.
-
#eql?(o) ⇒ Boolean
:nodoc:.
-
#favoured? ⇒ Boolean
Is the stat favoured?.
-
#initialize(name, rating = 0, opts = {}) ⇒ Stat
constructor
Creates a new stat.
-
#inspect ⇒ Object
:nodoc:.
Constructor Details
#initialize(name, rating = 0, opts = {}) ⇒ Stat
Creates a new stat.
Options include
- favoured
-
sets the favoured status of the stat
- caste
-
sets the caste status of the set
- specialities
-
Adds specialities to the set
- specs
-
see specialities
28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/exalted/stat.rb', line 28 def initialize(name, = 0, opts={}) if Hash === opts = = 0 end @name = name.downcase.to_sym @rating = @favoured = opts.delete(:favoured) || false @caste = opts.delete(:caste) || false specialities = opts.delete(:specialities) || opts.delete(:specs) || [] @specialities = specialities.sort end |
Instance Attribute Details
#caste=(value) ⇒ Object (writeonly)
set the caste status
18 19 20 |
# File 'lib/exalted/stat.rb', line 18 def caste=(value) @caste = value end |
#favoured=(value) ⇒ Object (writeonly)
set the favoured status
15 16 17 |
# File 'lib/exalted/stat.rb', line 15 def favoured=(value) @favoured = value end |
#name ⇒ Object
the stat’s name
6 7 8 |
# File 'lib/exalted/stat.rb', line 6 def name @name end |
#rating ⇒ Object
the stat’s rating
9 10 11 |
# File 'lib/exalted/stat.rb', line 9 def @rating end |
#specialities ⇒ Object
specialities the stat has
12 13 14 |
# File 'lib/exalted/stat.rb', line 12 def specialities @specialities end |
Instance Method Details
#==(o) ⇒ Object
63 64 65 66 67 68 69 70 71 72 73 74 |
# File 'lib/exalted/stat.rb', line 63 def ==(o) case o when String return true if self.name.to_s == o.downcase when Symbol return true if self.name == o when Exalted::Stat return self.eql?(o) else return false end end |
#caste? ⇒ Boolean
Is the stat a caste ability?
48 49 50 |
# File 'lib/exalted/stat.rb', line 48 def caste? (@caste) ? true : false end |
#eql?(o) ⇒ Boolean
:nodoc:
53 54 55 56 57 58 59 60 61 |
# File 'lib/exalted/stat.rb', line 53 def eql?(o) return false unless o.is_a?(Exalted::Stat) return false unless self. == o. return false unless self.favoured? == o.favoured? return false unless self.caste? == o.caste? return false unless self.specialities == o.specialities return true if self.name.eql?(o.name) false end |
#favoured? ⇒ Boolean
Is the stat favoured?
43 44 45 |
# File 'lib/exalted/stat.rb', line 43 def favoured? (@favoured) ? true : false end |
#inspect ⇒ Object
:nodoc:
77 78 79 |
# File 'lib/exalted/stat.rb', line 77 def inspect "#<Stat:#{@name}:#{}:#{@caste || @favoured}:#{@specialities.map {|s| "'#{s}'"}.join(",")}>" end |