Class: ExaltedMath::Node::Named
- Inherits:
-
ExaltedMath::Node
- Object
- ExaltedMath::Node
- ExaltedMath::Node::Named
- Defined in:
- lib/exalted_math/node/named.rb
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Instance Method Summary collapse
- #==(o) ⇒ Object
- #constant? ⇒ Boolean
-
#initialize(name) ⇒ Named
constructor
A new instance of Named.
- #valid?(stats) ⇒ Boolean
- #value(context = {}) ⇒ Object
Methods inherited from ExaltedMath::Node
Constructor Details
#initialize(name) ⇒ Named
Returns a new instance of Named.
7 8 9 |
# File 'lib/exalted_math/node/named.rb', line 7 def initialize(name) @name = name end |
Instance Attribute Details
#name ⇒ Object (readonly)
Returns the value of attribute name.
6 7 8 |
# File 'lib/exalted_math/node/named.rb', line 6 def name @name end |
Instance Method Details
#==(o) ⇒ Object
25 26 27 28 |
# File 'lib/exalted_math/node/named.rb', line 25 def ==(o) return false unless self.class === o self.name == o.name end |
#constant? ⇒ Boolean
11 12 13 |
# File 'lib/exalted_math/node/named.rb', line 11 def constant? false end |
#valid?(stats) ⇒ Boolean
30 31 32 |
# File 'lib/exalted_math/node/named.rb', line 30 def valid?(stats) stats.include?(name) end |
#value(context = {}) ⇒ Object
15 16 17 18 19 20 21 22 23 |
# File 'lib/exalted_math/node/named.rb', line 15 def value(context={}) if context.respond_to?(:fetch) context.fetch(name) { raise ContextError, name } elsif context.respond_to?(name) context.public_send(name) else raise ContextError, name end end |