class Flor::Pro::ToArray

Public Instance Methods

pre_execute() click to toggle source
# File lib/flor/pcore/to_array.rb, line 27
def pre_execute

  @node['ret'] = receive_payload_ret

  unatt_unkeyed_children
end
receive_last() click to toggle source
# File lib/flor/pcore/to_array.rb, line 34
def receive_last

  wrap_reply('ret' => (heap == 'to-object') ? to_object : to_array)
end

Protected Instance Methods

to_array() click to toggle source
# File lib/flor/pcore/to_array.rb, line 41
def to_array

  Flor.to_coll(@node['ret'])
end
to_object() click to toggle source
# File lib/flor/pcore/to_array.rb, line 46
def to_object

  r = @node['ret']

  fail Flor::FlorError.new('to-object wants an array (or an object)', self) \
    unless Flor.is_collection?(r)

  fail Flor::FlorError.new('to-object expects array with even length', self) \
    if r.is_a?(Array) && r.length.odd?

  r = r.each_slice(2).to_a if r.find { |e| ! e.is_a?(Array) }

  Hash[r]
end