Sha256: 15d2a312d8c742ef06be75c8d517d4e857eef1483608319f76e88ddb9e008c80

Contents?: true

Size: 388 Bytes

Versions: 5

Compression:

Stored size: 388 Bytes

Contents

# frozen_string_literal: true

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

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

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
redgraph-0.2.3 lib/redgraph/util.rb
redgraph-0.2.2 lib/redgraph/util.rb
redgraph-0.2.1 lib/redgraph/util.rb
redgraph-0.2.0 lib/redgraph/util.rb
redgraph-0.1.4 lib/redgraph/util.rb