Project

union

0.0
No release in over 3 years
Low commit activity in last 3 years
The union library provides an analog to a C/C++ union for Ruby. In this implementation a union is a kind of struct where multiple members may be defined, but only one member ever contains a non-nil value at any given time.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

>= 0
~> 3.9
 Project Readme

Ruby

Description

The union library provides the Ruby analog of a C union.

Installation

gem install union

Adding the trusted cert

gem cert --add <(curl -Ls https://raw.githubusercontent.com/djberg96/union/main/certs/djberg96_pub.pem)

Synopsis

require 'union'

Union.new('Human', :name, :age, :height)
h = Union::Human.new

# Only one attribute of the union may be set
h.name = 'Daniel' # => #<struct Union::Human name="Daniel", age=nil>
h.age  = 38       # => #<struct Union::Human name=nil, age=38>

Known issues or bugs

None that I'm aware of. Please report any bugs you find on the project page at on the github project page at https://github.com/djberg96/union.

License

Artistic-2.0

Copyright

(C) 2003-2021 Daniel J. Berger All Rights Reserved.

Warranty

This package is provided "as is" and without any express or implied warranties, including, without limitation, the implied warranties of merchantability and fitness for a particular purpose.

Author

Daniel J. Berger