Class: Flor::Pro::Cursor

Inherits:
Flor::Procedure show all
Defined in:
lib/flor/pcore/cursor.rb

Direct Known Subclasses

Loop

Constant Summary

Constants inherited from Flor::Procedure

Flor::Procedure::RVARS, Flor::Procedure::TRUE_ATTS

Instance Attribute Summary

Attributes inherited from Node

#message

Instance Method Summary collapse

Methods inherited from Flor::Procedure

[], core?, #debug_msg, #debug_tree, #end, #flank, #heap, inherited, make, names, #prepare_on_receive_last, #trigger_on_error

Methods inherited from Node

#child_id, #cnodes, #cnodes_any?, #cnodes_empty?, #deref, #descendant_of?, #domain, #exid, #fei, #from, #h, #initialize, #lookup_tree, #lookup_value, #message_or_node_payload, #nid, #node_closed?, #node_ended?, #node_open?, #node_payload, #node_payload_ret, #node_status, #node_status_flavour, #on_error_parent, #parent, #payload, #payload_ret, #point, #reheap, #to_procedure_node, #tree

Constructor Details

This class inherits a constructor from Flor::Node

Instance Method Details

#cancelObject



151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
# File 'lib/flor/pcore/cursor.rb', line 151

def cancel

  if %w[ continue move ].include?(fla = @message['flavour'])

    cid =
      fla == 'move' ?
      move_target_child_id :
      first_non_att_child_id

    @node['subs'] <<
      counter_next('subs')

    @node['on_receive_last'] =
      execute_child(cid, @node['subs'].last, 'orl' => fla)

  else

    @node['on_receive_last'] = nil
  end

  super
end

#cancel_when_closedObject



143
144
145
146
147
148
149
# File 'lib/flor/pcore/cursor.rb', line 143

def cancel_when_closed

  return cancel if node_status_flavour == 'on-error'
  return [] if @message['flavour'] != 'break'

  cancel
end

#pre_executeObject



93
94
95
96
97
# File 'lib/flor/pcore/cursor.rb', line 93

def pre_execute

  @node['atts'] = []
  @node['subs'] = []
end

#receive_attObject



115
116
117
118
# File 'lib/flor/pcore/cursor.rb', line 115

def receive_att

  receive_unkeyed_tag_att + super
end

#receive_firstObject



99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
# File 'lib/flor/pcore/cursor.rb', line 99

def receive_first

  # break/continue/move are set as variables so that they can
  # be aliases, it's useful in nested loops

  @node['vars'] = {
    'break' =>
      [ '_proc', { 'proc' => 'break', 'nid' => nid }, tree[-1] ],
    'continue' =>
      [ '_proc', { 'proc' => 'continue', 'nid' => nid }, tree[-1] ],
    'move' =>
      [ '_proc', { 'proc' => 'move', 'nid' => nid }, tree[-1] ] }

  super
end

#receive_last_attObject



134
135
136
137
138
139
140
141
# File 'lib/flor/pcore/cursor.rb', line 134

def receive_last_att

  start = att('start', 'initial')
  cid = start && find_child_id(start)
  @ncid = cid if cid

  super
end

#receive_non_attObject



120
121
122
123
124
125
126
127
128
129
130
131
132
# File 'lib/flor/pcore/cursor.rb', line 120

def receive_non_att

  if @ncid >= children.size
    if @message['orl'] == 'continue'
      @node['subs'] << counter_next('subs')
      execute_child(first_non_att_child_id, @node['subs'].last)
    else
      wrap_reply
    end
  else
    execute_child(@ncid, @node['subs'].last)
  end
end