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.



251
252
253
254
# File 'lib/core/nodes.rb', line 251

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.



249
250
251
# File 'lib/core/nodes.rb', line 249

def parent_nodes
  @parent_nodes
end

Instance Method Details



256
257
258
259
260
261
# File 'lib/core/nodes.rb', line 256

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