Module: Redgraph::Util

Included in:
Edge, Graph, Node
Defined in:
lib/redgraph/util.rb

Instance Method Summary collapse

Instance Method Details

#escape_value(x) ⇒ Object



12
13
14
15
16
17
18
19
# File 'lib/redgraph/util.rb', line 12

def escape_value(x)
  case x
  when Integer then x
  when NilClass then "''"
  else
    '"' + x.gsub('"', '\"') + '"'
  end
end

#properties_to_string(hash) ⇒ Object



5
6
7
8
9
10
# File 'lib/redgraph/util.rb', line 5

def properties_to_string(hash)
  return if hash.empty?
  "{" +
  hash.map {|k,v| "#{k}:#{escape_value(v)}" }.join(", ") +
  "}"
end