Class: Twb::Util::GMLedge
- Inherits:
-
Object
- Object
- Twb::Util::GMLedge
- Defined in:
- lib/twb/util/gmledge.rb
Instance Attribute Summary collapse
-
#cypherCreate ⇒ Object
readonly
Returns the value of attribute cypherCreate.
-
#from ⇒ Object
readonly
Returns the value of attribute from.
-
#properties ⇒ Object
Returns the value of attribute properties.
-
#relationship ⇒ Object
readonly
Returns the value of attribute relationship.
-
#to ⇒ Object
readonly
Returns the value of attribute to.
Instance Method Summary collapse
- #cypher_s ⇒ Object
- #dot ⇒ Object
- #dotquote(str) ⇒ Object
- #eql?(other) ⇒ Boolean
- #gml ⇒ Object
- #hash ⇒ Object
-
#initialize(from:, to:, relationship:, properties: {}) ⇒ GMLedge
constructor
Neo4J cypher variable quote character: ‘.
- #to_s ⇒ Object
Constructor Details
#initialize(from:, to:, relationship:, properties: {}) ⇒ GMLedge
Neo4J cypher variable quote character: ‘
31 32 33 34 35 36 37 38 39 |
# 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 |
Instance Attribute Details
#cypherCreate ⇒ Object (readonly)
Returns the value of attribute cypherCreate.
27 28 29 |
# File 'lib/twb/util/gmledge.rb', line 27 def cypherCreate @cypherCreate end |
#from ⇒ Object (readonly)
Returns the value of attribute from.
25 26 27 |
# File 'lib/twb/util/gmledge.rb', line 25 def from @from end |
#properties ⇒ Object
Returns the value of attribute properties.
26 27 28 |
# File 'lib/twb/util/gmledge.rb', line 26 def properties @properties end |
#relationship ⇒ Object (readonly)
Returns the value of attribute relationship.
25 26 27 |
# File 'lib/twb/util/gmledge.rb', line 25 def relationship @relationship end |
#to ⇒ Object (readonly)
Returns the value of attribute to.
25 26 27 |
# File 'lib/twb/util/gmledge.rb', line 25 def to @to end |
Instance Method Details
#cypher_s ⇒ Object
62 63 64 |
# File 'lib/twb/util/gmledge.rb', line 62 def cypher_s "(%s)-[:`%s`]->(%s)" % [@from.cypherID,@relationship,@to.cypherID] end |
#dot ⇒ Object
53 54 55 |
# File 'lib/twb/util/gmledge.rb', line 53 def dot "%s -> %s" % [dotquote(from.id), dotquote(to.id)] end |
#dotquote(str) ⇒ Object
57 58 59 60 |
# File 'lib/twb/util/gmledge.rb', line 57 def dotquote str ns = str.gsub(/(["])/,'\\"') return "\"#{ns}\"" end |
#eql?(other) ⇒ Boolean
41 42 43 |
# 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 ⇒ Object
66 67 68 |
# File 'lib/twb/util/gmledge.rb', line 66 def gml "%s -> %s" % [dotquote(from.id), dotquote(to.id)] end |
#hash ⇒ Object
45 46 47 |
# File 'lib/twb/util/gmledge.rb', line 45 def hash [@from.hash, @to.hash, @relationship, @properties].hash end |
#to_s ⇒ Object
49 50 51 |
# File 'lib/twb/util/gmledge.rb', line 49 def to_s "'#{@from.name}//{@from.id}' --#{@relationship}--> '#{@to.name}//#{@to.id}'" end |