class Twb::Util::GMLedge
Attributes
cypherCreate[R]
from[R]
@from - the origin node @to - the destination node @relationship - useful for categorizing the edge @properties - useful for categorizing the edge
properties[RW]
relationship[R]
@from - the origin node @to - the destination node @relationship - useful for categorizing the edge @properties - useful for categorizing the edge
to[R]
@from - the origin node @to - the destination node @relationship - useful for categorizing the edge @properties - useful for categorizing the edge
Public Class Methods
new(from:, to:, relationship:, properties: {})
click to toggle source
Neo4J cypher variable quote character: `
# File lib/twb/util/gmledge.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
Public Instance Methods
cypher_s()
click to toggle source
# File lib/twb/util/gmledge.rb, line 62 def cypher_s "(%s)-[:`%s`]->(%s)" % [@from.cypherID,@relationship,@to.cypherID] end
dot()
click to toggle source
# File lib/twb/util/gmledge.rb, line 53 def dot "%s -> %s" % [dotquote(from.id), dotquote(to.id)] end
dotquote(str)
click to toggle source
# File lib/twb/util/gmledge.rb, line 57 def dotquote str ns = str.gsub(/(["])/,'\\"') return "\"#{ns}\"" end
eql?(other)
click to toggle source
# File lib/twb/util/gmledge.rb, line 41 def eql? other @from == other.from && @to == other.to && @relationship == other.relationship && @properties == other.properties end
gml()
click to toggle source
# File lib/twb/util/gmledge.rb, line 66 def gml "%s -> %s" % [dotquote(from.id), dotquote(to.id)] end
hash()
click to toggle source
# File lib/twb/util/gmledge.rb, line 45 def hash [@from.hash, @to.hash, @relationship, @properties].hash end
to_s()
click to toggle source
# File lib/twb/util/gmledge.rb, line 49 def to_s "'#{@from.name}//{@from.id}' --#{@relationship}--> '#{@to.name}//#{@to.id}'" end