struct-for_pairs

Build Status Gem Version

Description

Struct will be able to constructed from key-value pairs.

Features

  • Pure Ruby :)

Usage

Build from Hash with Struct's Subclass

require 'struct/for_pairs'

FooBar = Struct.new :foo, :bar

foobar = FooBar.for_pairs bar: 456, foo: 123
foobar.foo #=> 123
foobar.bar #=> 456

And short cut with no named struct

foobar = Struct.for_pairs foo: 123, bar: 456
foobar.foo #=> 123
foobar.bar #=> 456

Requirements

Install

$ gem install struct-for_pairs

Link

License

The MIT X11 License
Copyright (c) 2012 Kenichi Kamiya
See MIT-LICENSE for further details.