Struct constructor for key-value pairs
Ruby
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
example
lib/struct
test
.gitignore
.travis.yml
.yardopts
Gemfile
MIT-LICENSE
README.md
Rakefile
struct-for_pairs.gemspec

README.md

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

Alases

  • from_pairs

Requirements

Install

$ gem install struct-for_pairs

Link

License

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