class Aspen::Node
Attributes
attributes[R]
label[R]
nickname[RW]
Public Class Methods
new(label: , attributes: {})
click to toggle source
# File lib/aspen/node.rb, line 12 def initialize(label: , attributes: {}) @label = label @attributes = attributes @nickname = nickname_from_first_attr_value end
Public Instance Methods
==(other)
click to toggle source
# File lib/aspen/node.rb, line 46 def ==(other) label == other.label && attributes == other.attributes && nickname == other.nickname end
attribute_string()
click to toggle source
# File lib/aspen/node.rb, line 38 def attribute_string attributes.to_s. gsub(/"(?<token>[[:alpha:]_]+)"=>/, '\k<token>: '). # This puts a single space inside curly braces. gsub(/\{(\s*)/, "{ "). gsub(/(\s*)\}/, " }") end
nickname_from_first_attr_value()
click to toggle source
# File lib/aspen/node.rb, line 18 def nickname_from_first_attr_value "#{@label}-#{@attributes.values.first}".parameterize.underscore end
nickname_node()
click to toggle source
# File lib/aspen/node.rb, line 30 def nickname_node "(#{nickname})" end
signature()
click to toggle source
# File lib/aspen/node.rb, line 34 def signature "(#{label})" end
to_cypher()
click to toggle source
# File lib/aspen/node.rb, line 22 def to_cypher if nickname "(#{nickname}:#{label} #{ attribute_string })" else "(#{label} #{ attribute_string })" end end