Sha256: 3dd215f79d8f46a3ede10e5c8920ac83ddbf0521c411463491d1e1f018d76572

Contents?: true

Size: 493 Bytes

Versions: 1

Compression:

Stored size: 493 Bytes

Contents

require "to_dots/version"
require_relative './hash'
require_relative './array'

module ToDots
  def self.to_dots(object, result = [], prefix = '')
    if object.respond_to?(:to_hash)
      object.each do |key, value|
        to_dots(value, result, "#{prefix}#{'.' unless prefix.empty?}#{key}")
      end
    elsif object.is_a?(Array)
      object.each do |value|
        to_dots(value, result, prefix.to_s)
      end
    else
      result << "#{prefix}.#{object}"
    end
    result
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
to_dots-0.2.2 lib/to_dots.rb