Hash to dot notation.
Add this line to your application's Gemfile:
gem 'dothash'
And then execute:
$ bundle
Or install it yourself as:
$ gem install dothash
require "dothash"
hash = { x: { y: 1, z: { a1: 8, a2: 10 } }, v: [1, { y: 2, z: 3 }] }
dhash = Dothash::Hash.with_dots hash
puts dhash
# {"x.y"=>1, "x.z.a1"=>8, "x.z.a2"=>10, "v.0"=>1, "v.1.y"=>2, "v.1.z"=>3}
puts dhash.class
# Hash
dhash_1 = Dothash::Hash.with_dots_one_based hash
puts dhash
# {"x.y"=>1, "x.z.a1"=>8, "x.z.a2"=>10, "v.1"=>1, "v.2.y"=>2, "v.2.z"=>3}
hash2 = Dothash::Hash.without_dots(dhash)
puts hash2
# {:x=>{:y=>1, :z=>{:a1=>8, :a2=>10}}, :v=>{:"0"=>1, :"1"=>{:y=>2, :z=>3}}}
See semver.org
- Fork it
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Add some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create new Pull Request