Module: Eco::Data::Locations::NodeBase::Serial

Includes:
Convert, Treeify
Included in:
Builder
Defined in:
lib/eco/data/locations/node_base/serial.rb

Instance Attribute Summary

Attributes included from Language::AuxiliarLogger

#logger

Instance Method Summary collapse

Methods included from Convert

#csv_from, #empty_array, #empty_level_tracker_hash, #hash_tree_to_tree_csv, #log_pretty_inspect, #normalize_arrays, #report_repeated_node_ids

Methods included from Language::AuxiliarLogger

#log

Methods included from Treeify

#serialize_node, #treeify

Instance Method Details

#nodes_to_csv_list(nodes) ⇒ CSV::Table

Returns ready to dump into a nodes list csv (rows are nodes; a column holds parent_id).

Returns:

  • (CSV::Table)

    ready to dump into a nodes list csv (rows are nodes; a column holds parent_id)



21
22
23
24
# File 'lib/eco/data/locations/node_base/serial.rb', line 21

def nodes_to_csv_list(nodes)
  tree = Eco::API::Organization::TagTree.new(treeify(nodes))
  Eco::CSV::Table.new(tree.as_nodes_json)
end

#nodes_to_csv_tree(nodes) ⇒ CSV::Table

Returns ready to dump into a hierarhical csv (columns are tree levels).

Returns:

  • (CSV::Table)

    ready to dump into a hierarhical csv (columns are tree levels)



15
16
17
# File 'lib/eco/data/locations/node_base/serial.rb', line 15

def nodes_to_csv_tree(nodes)
  hash_tree_to_tree_csv(treeify(nodes))
end

#serializer(item) ⇒ Proc

Returns the serializer to be used.

Parameters:

Returns:

  • (Proc)

    the serializer to be used.



8
9
10
11
# File 'lib/eco/data/locations/node_base/serial.rb', line 8

def serializer(item)
  raise "Execting a chidren of NodeBase. Given: #{item.class}" unless item.class < Eco::Data::Locations::NodeBase
  item.serializer
end