Class: Twb::Util::Graphedge
- Inherits:
-
Object
- Object
- Twb::Util::Graphedge
- Defined in:
- lib/twb/util/graphedge.rb
Instance Attribute Summary collapse
-
#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
- #dot ⇒ Object
- #eql?(other) ⇒ Boolean
- #gml ⇒ Object
- #hash ⇒ Object
-
#initialize(from:, to:, relationship:, properties: {}) ⇒ Graphedge
constructor
Neo4J cypher variable quote character: ‘.
- #to_s ⇒ Object
Constructor Details
#initialize(from:, to:, relationship:, properties: {}) ⇒ Graphedge
Neo4J cypher variable quote character: ‘
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
#from ⇒ Object (readonly)
Returns the value of attribute from.
25 26 27 |
# File 'lib/twb/util/graphedge.rb', line 25 def from @from end |
#properties ⇒ Object
Returns the value of attribute properties.
26 27 28 |
# File 'lib/twb/util/graphedge.rb', line 26 def properties @properties end |
#relationship ⇒ Object (readonly)
Returns the value of attribute relationship.
25 26 27 |
# File 'lib/twb/util/graphedge.rb', line 25 def relationship @relationship end |
#to ⇒ Object (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
#dot ⇒ Object
53 54 55 |
# File 'lib/twb/util/graphedge.rb', line 53 def dot "%s -> %s" % [from.dotid, to.dotid] end |
#eql?(other) ⇒ 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 |
#gml ⇒ Object
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 |
#hash ⇒ Object
45 46 47 |
# File 'lib/twb/util/graphedge.rb', line 45 def hash [@from.hash, @to.hash, @relationship, @properties].hash end |
#to_s ⇒ Object
49 50 51 |
# File 'lib/twb/util/graphedge.rb', line 49 def to_s "'#{@from.name}//{@from.id}' --#{@relationship}--> '#{@to.name}//#{@to.id}'" end |