class Flor::Pro::Att
Public Instance Methods
execute()
click to toggle source
# File lib/flor/pcore/_att.rb, line 7 def execute return wrap_reply if children == [ [ '_', [], tree[2] ] ] # spares 1 message pt = parent_node['tree'] return wrap_reply if pt && pt[0] == '_apply' m = "pre_execute_#{children[0][0]}" send(m) if respond_to?(m, true) execute_child(0, nil, 'accept_symbol' => children.size > 1) end
receive()
click to toggle source
# File lib/flor/pcore/_att.rb, line 21 def receive if children.size < 2 receive_unkeyed else receive_keyed end end
Protected Instance Methods
parent_is_trap?()
click to toggle source
# File lib/flor/pcore/_att.rb, line 171 def parent_is_trap? pt = parent_node_tree; return false unless pt pt0 = pt[0]; return false unless pt0.is_a?(String) pro = Flor::Procedure[pt0]; return false unless pro pro.names.include?('trap') end
pre_execute_boolean_attribute()
click to toggle source
For example, turns ‘sequence flank` into `sequence flank: true`
# File lib/flor/pcore/_att.rb, line 37 def pre_execute_boolean_attribute return unless children.size == 1 t = @node['tree'] = Flor.dup(tree) t[1] << [ '_boo', true, @node['tree'][2] ] end
pre_execute_vars()
click to toggle source
# File lib/flor/pcore/_att.rb, line 50 def pre_execute_vars return unless children.size == 2 && children[1][0] == '_obj' t = tree return if t[1][1][1] == 0 # [ '_obj', 0, 123 ] # add `quote: 'keys'` to the _obj so that they may be `k0:` or `'k0':` t = @node['tree'] = Flor.dup(t) t[1][1][1].unshift([ '_att', [ [ 'quote', [], -1 ], [ '_sqs', 'keys', -1 ] ], -1 ]) end
receive_att(key)
click to toggle source
# File lib/flor/pcore/_att.rb, line 99 def receive_att(key) if parent_node['atts'] parent_node['atts'] << [ unref(key), payload['ret'] ] parent_node['mtime'] = Flor.tstamp elsif key == nil && parent_node['rets'] parent_node['rets'] << payload['ret'] parent_node['mtime'] = Flor.tstamp end payload['ret'] = @node['ret'] if key wrap_reply end
receive_child_on_cancel()
click to toggle source
# File lib/flor/pcore/_att.rb, line 245 def receive_child_on_cancel if pn = parent_node; pn['child_on_cancel'] = payload_ret; end; wrap_reply end
Also aliased as: receive_children_on_cancel
receive_child_on_error()
click to toggle source
# File lib/flor/pcore/_att.rb, line 242 def receive_child_on_error if pn = parent_node; pn['child_on_error'] = payload_ret; end; wrap_reply end
Also aliased as: receive_children_on_error
receive_child_on_timeout()
click to toggle source
# File lib/flor/pcore/_att.rb, line 248 def receive_child_on_timeout if pn = parent_node; pn['child_on_timeout'] = payload_ret; end; wrap_reply end
Also aliased as: receive_children_on_timeout
receive_disabled()
click to toggle source
Might turn the “disable” flag to true, which forces the parent node (the node bearing the att under evaluation right now) to terminate immediately (by replying to its own parent node).
# File lib/flor/pcore/_att.rb, line 234 def receive_disabled wrap_reply('disable' => Flor.true?(payload['ret'])) end
Also aliased as: receive_off, receive_disable
receive_flank()
click to toggle source
# File lib/flor/pcore/_att.rb, line 221 def receive_flank return wrap_reply unless Flor.true?(payload['ret']) return wrap_reply unless parent_node parent_node_procedure.flank + wrap_reply end
receive_keyed()
click to toggle source
# File lib/flor/pcore/_att.rb, line 74 def receive_keyed if Flor.child_id(@message['from']) == 0 ret = payload['ret'] @node['key'] = k = unref(ret, :key) as = (parent_node || {})['atts_accepting_symbols'] || [] execute_child(1, nil, 'accept_symbol' => as.include?(k)) else k = @node['key'] m = "receive_#{k}" respond_to?(m, true) ? send(m) : receive_att(k) end end
receive_on_cancel()
click to toggle source
# File lib/flor/pcore/_att.rb, line 218 def receive_on_cancel; store_on(:cancel); wrap_reply; end
receive_on_error()
click to toggle source
# File lib/flor/pcore/_att.rb, line 217 def receive_on_error; store_on(:error); wrap_reply; end
receive_on_timeout()
click to toggle source
# File lib/flor/pcore/_att.rb, line 219 def receive_on_timeout; store_on(:timeout); wrap_reply; end
receive_ret()
click to toggle source
# File lib/flor/pcore/_att.rb, line 198 def receive_ret if pn = parent_node pn['aret'] = Flor.dup(payload['ret']) end wrap_reply end
receive_tag()
click to toggle source
# File lib/flor/pcore/_att.rb, line 179 def receive_tag return receive_att('tags') if parent_is_trap? ret = payload['ret'] ret = unref(ret, :att) tags = Array(ret) return wrap_reply if tags.empty? (parent_node['tags'] ||= []).concat(tags) parent_node['tags'].uniq! wrap('point' => 'entered', 'tags' => tags) + wrap_reply end
Also aliased as: receive_tags
receive_timeout()
click to toggle source
# File lib/flor/pcore/_att.rb, line 207 def receive_timeout n = parent m = wrap_cancel('nid' => n, 'flavour' => 'timeout').first t = payload['ret'] wrap_schedule('type' => 'in', 'string' => t, 'nid' => n, 'message' => m) + wrap_reply end
receive_unkeyed()
click to toggle source
receive phase
# File lib/flor/pcore/_att.rb, line 69 def receive_unkeyed receive_att(nil) end
receive_vars()
click to toggle source
‘vars: { … }` inits a scope for the parent node `vars: ’copy’‘ copies the parent scope and use as local scope `vars: [ ’a’, ‘b’ ]‘ inits a new scope containing vars a and b
# File lib/flor/pcore/_att.rb, line 118 def receive_vars vs = payload['ret'] if vs.is_a?(Array) key, list = vlist(vs) # 'vwlist' var white iist, 'vblist' black list parent_node[key] = list else (parent_node['vars'] ||= {}).merge!(vdict(vs)) end wrap('ret' => @node['ret']) end
unref(k, flavour=:key)
click to toggle source
# File lib/flor/pcore/_att.rb, line 88 def unref(k, flavour=:key) return k unless Flor.is_tree?(k) return k unless k[1].is_a?(Hash) return k unless %w[ _proc _tasker _func ].include?(k[0]) (flavour == :key ? nil : k[1]['oref']) || k[1]['ref'] || k[1]['proc'] || k[1]['tasker'] end
vdict(vs)
click to toggle source
# File lib/flor/pcore/_att.rb, line 132 def vdict(vs) case vs when Hash vs when 'copy', '*' @executor.vars(nid) # all the vars known at that point else fail Flor::FlorError.new( "vars: doesn't know how to deal with #{vs.inspect}", self) end end
vlist(vs)
click to toggle source
# File lib/flor/pcore/_att.rb, line 145 def vlist(vs) mode = case vs.first when '+' then '+' when '-', '^', '!' then '-' #else nil end vs.shift if mode vs = vs .collect { |v| if Flor.is_regex_tree?(v) Flor.to_regex(v) else fail Flor::FlorError.new( "vars: is limited to 1st level, #{v.inspect} doesn't comply", self ) if v.index('.') v end } mode = (mode || '+') == '+' ? 'vwlist' : 'vblist' [ mode, vs ] end