Class: ActiveWarehouse::Aggregate::DwarfAggregate::Node
- Inherits:
-
Object
- Object
- ActiveWarehouse::Aggregate::DwarfAggregate::Node
- Defined in:
- lib/active_warehouse/aggregate/dwarf_aggregate.rb
Constant Summary collapse
- @@sequence =
0
Instance Attribute Summary collapse
-
#all_cell ⇒ Object
A special cell which will hold either a reference to a sub node or the aggregate values for all of the values in the node’s cells.
-
#closed ⇒ Object
Set the true if the node is closed.
-
#index ⇒ Object
readonly
Reader accessor for the node index, a sequential number identifying order of creation.
-
#leaf ⇒ Object
Set to true if this node is a leaf node.
-
#parent ⇒ Object
The parent cell or nil.
-
#processed ⇒ Object
Set to true if the node has been processed.
Instance Method Summary collapse
- #add_cell(cell) ⇒ Object
-
#cells ⇒ Object
Return an array of cells for the node.
- #child(key) ⇒ Object
- #children ⇒ Object
- #closed? ⇒ Boolean
- #has_cell_with_key?(key) ⇒ Boolean
-
#initialize(key = nil, parent_cell = nil) ⇒ Node
constructor
Initialize the node with a cell that has the given key.
- #keys ⇒ Object
- #leaf? ⇒ Boolean
- #processed? ⇒ Boolean
- #to_s ⇒ Object
Constructor Details
#initialize(key = nil, parent_cell = nil) ⇒ Node
Initialize the node with a cell that has the given key
304 305 306 307 308 309 310 311 312 |
# File 'lib/active_warehouse/aggregate/dwarf_aggregate.rb', line 304 def initialize(key=nil, parent_cell=nil) @closed = false @processed = false @parent = parent_cell @parent.child = self if @parent @index = @@sequence += 1 #puts "creating node #{@index} with parent: #{@parent}" add_cell(Cell.new(key)) if key end |
Instance Attribute Details
#all_cell ⇒ Object
A special cell which will hold either a reference to a sub node or the aggregate values for all of the values in the node’s cells
284 285 286 |
# File 'lib/active_warehouse/aggregate/dwarf_aggregate.rb', line 284 def all_cell @all_cell end |
#closed ⇒ Object
Set the true if the node is closed
290 291 292 |
# File 'lib/active_warehouse/aggregate/dwarf_aggregate.rb', line 290 def closed @closed end |
#index ⇒ Object (readonly)
Reader accessor for the node index, a sequential number identifying order of creation
299 300 301 |
# File 'lib/active_warehouse/aggregate/dwarf_aggregate.rb', line 299 def index @index end |
#leaf ⇒ Object
Set to true if this node is a leaf node
296 297 298 |
# File 'lib/active_warehouse/aggregate/dwarf_aggregate.rb', line 296 def leaf @leaf end |
#parent ⇒ Object
The parent cell or nil
287 288 289 |
# File 'lib/active_warehouse/aggregate/dwarf_aggregate.rb', line 287 def parent @parent end |
#processed ⇒ Object
Set to true if the node has been processed
293 294 295 |
# File 'lib/active_warehouse/aggregate/dwarf_aggregate.rb', line 293 def processed @processed end |
Instance Method Details
#add_cell(cell) ⇒ Object
353 354 355 356 |
# File 'lib/active_warehouse/aggregate/dwarf_aggregate.rb', line 353 def add_cell(cell) cell.node = self cells << cell end |
#cells ⇒ Object
Return an array of cells for the node
315 316 317 |
# File 'lib/active_warehouse/aggregate/dwarf_aggregate.rb', line 315 def cells @cells ||= [] end |
#child(key) ⇒ Object
330 331 332 333 334 335 |
# File 'lib/active_warehouse/aggregate/dwarf_aggregate.rb', line 330 def child(key) cells.each do |cell| return cell.child if cell.key == key end return nil end |
#children ⇒ Object
337 338 339 |
# File 'lib/active_warehouse/aggregate/dwarf_aggregate.rb', line 337 def children cells.collect { |cell| cell.child }.compact end |
#closed? ⇒ Boolean
341 342 343 |
# File 'lib/active_warehouse/aggregate/dwarf_aggregate.rb', line 341 def closed? closed end |
#has_cell_with_key?(key) ⇒ Boolean
323 324 325 326 327 328 |
# File 'lib/active_warehouse/aggregate/dwarf_aggregate.rb', line 323 def has_cell_with_key?(key) cells.each do |cell| return true if cell.key == key end return false end |
#keys ⇒ Object
319 320 321 |
# File 'lib/active_warehouse/aggregate/dwarf_aggregate.rb', line 319 def keys cells.collect { |cell| cell.key } end |
#leaf? ⇒ Boolean
349 350 351 |
# File 'lib/active_warehouse/aggregate/dwarf_aggregate.rb', line 349 def leaf? leaf end |
#processed? ⇒ Boolean
345 346 347 |
# File 'lib/active_warehouse/aggregate/dwarf_aggregate.rb', line 345 def processed? processed end |
#to_s ⇒ Object
363 364 365 |
# File 'lib/active_warehouse/aggregate/dwarf_aggregate.rb', line 363 def to_s index.to_s end |