Class: ExaltedMath::Node::Maximum
- Inherits:
-
List
- Object
- ExaltedMath::Node
- List
- ExaltedMath::Node::Maximum
- Defined in:
- lib/exalted_math/node/maximum.rb
Instance Attribute Summary collapse
-
#count ⇒ Object
readonly
Returns the value of attribute count.
Attributes inherited from List
Instance Method Summary collapse
- #==(o) ⇒ Object
-
#initialize(nodes = [], count) ⇒ Maximum
constructor
A new instance of Maximum.
- #values(context = {}) ⇒ Object
Methods inherited from List
Methods inherited from ExaltedMath::Node
#constant?, #simplify, #valid?, #value
Constructor Details
#initialize(nodes = [], count) ⇒ Maximum
Returns a new instance of Maximum.
9 10 11 12 |
# File 'lib/exalted_math/node/maximum.rb', line 9 def initialize(nodes=[],count) super @count = count end |
Instance Attribute Details
#count ⇒ Object (readonly)
Returns the value of attribute count.
7 8 9 |
# File 'lib/exalted_math/node/maximum.rb', line 7 def count @count end |
Instance Method Details
#==(o) ⇒ Object
18 19 20 21 |
# File 'lib/exalted_math/node/maximum.rb', line 18 def ==(o) return false unless super count == o.count end |
#values(context = {}) ⇒ Object
14 15 16 |
# File 'lib/exalted_math/node/maximum.rb', line 14 def values(context={}) nodes.map { |node| node.value(context) }.sort.slice(-count, count) end |