Skip to content
This repository has been archived by the owner. It is now read-only.
Struct constructor for key-value pairs (*archived since https://bugs.ruby-lang.org/issues/11925)
Ruby
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
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.

You can’t perform that action at this time.