Sha256: 470df3bb422a0e849b5cd68d8bf494ec46ddd1395fe97e4c947f29fb59352753
Contents?: true
Size: 835 Bytes
Versions: 16
Compression:
Stored size: 835 Bytes
Contents
require 'json' def parse_geoff_node(expr) GeoffNodeMatcher.new(expr) end def parse_geoff_relation(expr) GeoffRelationshipMatcher.new(expr) end def strip_whitespace s s.gsub(/^\s*/, '').chomp end class GeoffNodeMatcher @@regex = /\((\w+)\) (.*)/ def initialize(expression) @@regex.match expression @node_name = $1 @attributes = JSON.parse($2, symbolize_names: true) rescue @attributes = {} end def named?(name) @node_name == name end def has_attribute?(name, value) @attributes[name.to_sym] == value end end class GeoffRelationshipMatcher @@regex = /\((.*)\)-\[\:(.*)\]->\((.*)\)/ def initialize(expression) @@regex.match expression @source_name = $1 @relationship_name = $2 @dest_name = $3 end def named?(name) @relationship_name == name end end
Version data entries
16 entries across 16 versions & 1 rubygems