Class: Cassowary::Strength

Inherits:
Object show all
Defined in:
lib/strength.rb

Constant Summary collapse

RequiredStrength =
new "required"
StrongStrength =
new "strong", SymbolicWeight.new([1.0])
MediumStrength =
new "medium", SymbolicWeight.new([0.0, 1.0])
WeakStrength =
new "weak", SymbolicWeight.new([0.0, 0.0, 1.0])

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name = nil, symbolic_weight = nil) ⇒ Strength

Returns a new instance of Strength.



7
8
9
10
# File 'lib/strength.rb', line 7

def initialize(name = nil, symbolic_weight = nil)
  self.name = name
  self.symbolic_weight = symbolic_weight
end

Instance Attribute Details

#nameObject

Returns the value of attribute name.



5
6
7
# File 'lib/strength.rb', line 5

def name
  @name
end

#symbolic_weightObject

Returns the value of attribute symbolic_weight.



5
6
7
# File 'lib/strength.rb', line 5

def symbolic_weight
  @symbolic_weight
end

Instance Method Details

#eachObject



20
21
22
23
24
# File 'lib/strength.rb', line 20

def each
  [RequiredStrength, StrongStrength, MediumStrength, WeakStrength].each do |str|
    yield str
  end
end

#inspectObject



16
17
18
# File 'lib/strength.rb', line 16

def inspect
  "#{name}"
end

#required?Boolean

Returns:

  • (Boolean)


12
13
14
# File 'lib/strength.rb', line 12

def required?
  self == RequiredStrength
end