Class: ExaltedMath::Node::Maximum

Inherits:
List show all
Defined in:
lib/exalted_math/node/maximum.rb

Instance Attribute Summary collapse

Attributes inherited from List

#nodes

Instance Method Summary collapse

Methods inherited from List

#constant?, #simplify, #value

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

#countObject (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