Class: Twb::Util::Graphedge

Inherits:
Object
  • Object
show all
Defined in:
lib/twb/util/graphedge.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(from:, to:, relationship:, properties: {}) ⇒ Graphedge

Neo4J cypher variable quote character: ‘

Raises:

  • (ArgumentError)


31
32
33
34
35
36
37
38
39
# File 'lib/twb/util/graphedge.rb', line 31

def initialize (from:, to:, relationship:, properties: {})
  raise ArgumentError.new("from: parameter must be a Graphnode, is a '#{from.class}'") unless from.is_a? Twb::Util::Graphnode
  raise ArgumentError.new(  "to: parameter must be a Graphnode, is a '#{to.class}'"  ) unless   to.is_a? Twb::Util::Graphnode
  @from         = from
  @to           = to
  @relationship = relationship
  @properties   = properties
  # @cypherCreate = "CREATE  #{cypher_s}"
end

Instance Attribute Details

#fromObject (readonly)

Returns the value of attribute from.



25
26
27
# File 'lib/twb/util/graphedge.rb', line 25

def from
  @from
end

#propertiesObject

Returns the value of attribute properties.



26
27
28
# File 'lib/twb/util/graphedge.rb', line 26

def properties
  @properties
end

#relationshipObject (readonly)

Returns the value of attribute relationship.



25
26
27
# File 'lib/twb/util/graphedge.rb', line 25

def relationship
  @relationship
end

#toObject (readonly)

Returns the value of attribute to.



25
26
27
# File 'lib/twb/util/graphedge.rb', line 25

def to
  @to
end

Instance Method Details

#dotObject



53
54
55
# File 'lib/twb/util/graphedge.rb', line 53

def dot
  "%s  ->  %s" % [from.dotid, to.dotid]
end

#eql?(other) ⇒ Boolean

Returns:

  • (Boolean)


41
42
43
# File 'lib/twb/util/graphedge.rb', line 41

def eql? other
  @from == other.from && @to == other.to && @relationship == other.relationship && @properties == other.properties
end

#gmlObject



57
58
59
# File 'lib/twb/util/graphedge.rb', line 57

def gml
  "edge [    id %s\n    source \"%s\"\n    target \"%s\"\n  ]" % [@from, @to]
end

#hashObject



45
46
47
# File 'lib/twb/util/graphedge.rb', line 45

def hash
  [@from.hash, @to.hash, @relationship, @properties].hash
end

#to_sObject



49
50
51
# File 'lib/twb/util/graphedge.rb', line 49

def to_s
  "'#{@from.name}//{@from.id}' --#{@relationship}--> '#{@to.name}//#{@to.id}'"
end