No commit activity in last 3 years
No release in over 3 years
Three proposed new methods for Hash: map_pair, map_key, and map_value.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 10.3
 Project Readme

Hashy

Build Status

A trivial implementation of three new Hash methods: map_pair, map_key & map_value. It's been proposed that these methods be added to the Ruby language. They're each just one-liners in Ruby but it seems they're quite handy.

Installation

gem install hashy

Usage

require 'hashy'

hash = { aim: true }
#=> {:aim=>true}

hash.map_pair { |k, v| [k.to_s, v.to_s] }
#=> {"aim"=>"true"}

hash.map_key(&:to_s)
#=> {"aim"=>true}

hash.map_value(&:to_s)
#=> {:aim=>"true"}

Credits

  • dsisnero's initial post on ruby-core
  • nobu's suggestion of appropriate method names and making a gem
  • heftig's refactoring of the code

Thanks all!