Class: Exalted::Stat

Inherits:
Object
  • Object
show all
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

Instance Method Summary collapse

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, rating = 0, opts={})
  if Hash === rating
    opts = rating
    rating = 0
  end

  @name = name.downcase.to_sym
  @rating = 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

#nameObject

the stat’s name



6
7
8
# File 'lib/exalted/stat.rb', line 6

def name
  @name
end

#ratingObject

the stat’s rating



9
10
11
# File 'lib/exalted/stat.rb', line 9

def rating
  @rating
end

#specialitiesObject

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?

Returns:

  • (Boolean)


48
49
50
# File 'lib/exalted/stat.rb', line 48

def caste?
  (@caste) ? true : false
end

#eql?(o) ⇒ Boolean

:nodoc:

Returns:

  • (Boolean)


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.rating == o.rating
  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?

Returns:

  • (Boolean)


43
44
45
# File 'lib/exalted/stat.rb', line 43

def favoured?
  (@favoured) ? true : false
end

#inspectObject

:nodoc:



77
78
79
# File 'lib/exalted/stat.rb', line 77

def inspect
  "#<Stat:#{@name}:#{rating}:#{@caste || @favoured}:#{@specialities.map {|s| "'#{s}'"}.join(",")}>"
end