Class: Neography::Node

Inherits:
PropertyContainer show all
Includes:
Equal, Index, NodePath, NodeRelationship, Property
Defined in:
lib/neography/node.rb

Constant Summary

Constants included from NodeRelationship

Neography::NodeRelationship::DIRECTIONS

Instance Attribute Summary collapse

Attributes inherited from PropertyContainer

#neo_id

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Property

#[], #[]=, #add_or_remove_ostruct_member, #attributes, #method_missing, #new_ostruct_member, #node?, #remove_ostruct_member, #reset_properties, #set_properties

Methods included from Equal

#==, #eql?, #equal?

Methods included from NodePath

#all_paths_to, #all_shortest_paths_to, #all_simple_paths_to, #path_to, #shortest_path_to, #simple_path_to

Methods included from NodeRelationship

#both, #incoming, #outgoing, #rel, #rel?, #rels

Methods included from Index

#add_to_index, included, #remove_from_index

Methods inherited from PropertyContainer

#initialize

Constructor Details

This class inherits a constructor from Neography::PropertyContainer

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Neography::Property

Instance Attribute Details

#neo_serverObject

Returns the value of attribute neo_server.



9
10
11
# File 'lib/neography/node.rb', line 9

def neo_server
  @neo_server
end

Class Method Details

.create(props = nil, db = Neography::Rest.new) ⇒ Object

Raises:

  • (ArgumentError)


11
12
13
14
15
16
17
# File 'lib/neography/node.rb', line 11

def self.create(props = nil, db = Neography::Rest.new)
  raise ArgumentError.new("syntax deprecated") if props.is_a?(Neography::Rest)

  node = self.new(db.create_node(props))
  node.neo_server = db
  node
end

.create_unique(index, key, value, props = nil, db = Neography::Rest.new) ⇒ Object

Raises:

  • (ArgumentError)


19
20
21
22
23
24
25
# File 'lib/neography/node.rb', line 19

def self.create_unique(index, key, value, props = nil, db = Neography::Rest.new)
  raise ArgumentError.new("syntax deprecated") if props.is_a?(Neography::Rest)

  node = self.new(db.create_unique_node(index, key, value, props))
  node.neo_server = db
  node
end

.load(node, db = Neography::Rest.new) ⇒ Object

Raises:

  • (ArgumentError)


27
28
29
30
31
32
33
34
35
36
# File 'lib/neography/node.rb', line 27

def self.load(node, db = Neography::Rest.new)
  raise ArgumentError.new("syntax deprecated") if node.is_a?(Neography::Rest)
  node = node.first if node.kind_of?(Array)
  node = db.get_node(node) if (node.to_s.match(/^\d+$/) or node.to_s.split("/").last.match(/^\d+$/))
  if node
    node = self.new(node)
    node.neo_server = db
  end
  node
end

Instance Method Details

#delObject



43
44
45
# File 'lib/neography/node.rb', line 43

def del
  neo_server.delete_node!(self.neo_id)
end

#exist?Boolean

Returns:

  • (Boolean)


47
48
49
50
51
52
53
54
# File 'lib/neography/node.rb', line 47

def exist?
  begin
    neo_server.get_node(self.neo_id)
    true
  rescue NodeNotFoundException
    false
  end
end

#find(*args) ⇒ Object



38
39
40
41
# File 'lib/neography/node.rb', line 38

def find(*args)
  node = self.new
  node.find(args)
end

#labelsObject

List of labels of current node. Returns array of strings



59
60
61
# File 'lib/neography/node.rb', line 59

def labels
  self.neo_server.get_node_labels(self.neo_id)
end