Class: Ruleby::Core::Printable

Inherits:
Object
  • Object
show all
Defined in:
lib/core/nodes.rb

Overview

Any node in the network that needs to be printed extends this class. It provides handles to the nodes above it in the network. These are not used for matching (i.e. no backward-chaining).

Direct Known Subclasses

Node

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializePrintable

Returns a new instance of Printable.



262
263
264
265
# File 'lib/core/nodes.rb', line 262

def initialize
  # this is only used for printing the network, not for matching
  @parent_nodes = [] 
end

Instance Attribute Details

#parent_nodesObject (readonly)

Returns the value of attribute parent_nodes.



260
261
262
# File 'lib/core/nodes.rb', line 260

def parent_nodes
  @parent_nodes
end

Instance Method Details



267
268
269
270
271
272
# File 'lib/core/nodes.rb', line 267

def print(tab)
  puts tab + to_s
  @parent_nodes.each do |out_node|
    out_node.print('  '+tab)
  end
end