Module: Jumoku::RawTree::Node

Defined in:
lib/jumoku/raw_tree_node.rb

Overview

This module describes RawTree nodes.

You may also use this module as a mixin to have a class behave as a RawTree node, while customizing behaviors.

Instance Method Summary collapse

Instance Method Details

#create(name, data = OpenObject.new, children = []) ⇒ OpenObject

Creates a new node.

Parameters:

  • name (#to_s, #to_sym)

    a valid name, considering the :names_as options passed to the raw tree you want to create a node for.

  • data (Object) (defaults to: OpenObject.new)

    the data field type to use. Defaults to an empty OpenObject

  • children (Array(#to_s)) (defaults to: [])

    an array of children nodes ids

Returns:

  • (OpenObject)

    the node as an OpenObject instance



18
19
20
21
22
23
24
# File 'lib/jumoku/raw_tree_node.rb', line 18

def create name, data = OpenObject.new, children = []
  @name = name
  @data = data
  @children = children

  OpenObject.new(:name => @name, :data => @data, :children => @children)
end