class Operation
The Operation
class is the Hitsuji
representation of an equation, and its properties include a name, a value and a block. The value is an Linker
with read-write properties, and the values in this Linker
are parsed into the block for execution. This block is only executed upon read of dependent values. Once the Operation
is bound, a seperate method must be used to read them. Linkers are the main interface between Items and Operations. Examples of its use can be seen in the documentation for the Hitsuji.operation
method.
Attributes
block[R]
input[RW]
name[RW]
Public Class Methods
new(name, input, block)
click to toggle source
# File lib/subsystem.rb, line 39 def initialize(name, input, block) @name = name @input = input src = MethodSource.source_helper(block.source_location) @block = 'proc ' + src.match(/(do|\{)+?(.|\s)*(end|\})+?/).to_s end
Public Instance Methods
call()
click to toggle source
# File lib/subsystem.rb, line 46 def call eval(@block).call(recurse(@input.value)) end
Private Instance Methods
recurse(obj)
click to toggle source
# File lib/subsystem.rb, line 50 def recurse(obj) res = [] obj.each do |n| res << n.value if n.class == Item res << n.call_proc if n.class == Operation res << recurse(n.value) if n.class == Linker end res end