Skip to content
Struct will be able to alias the members name.
Ruby
Find file
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.
example
lib/struct
test
.gitignore
.travis.yml
.yardopts
Gemfile
History.md
LICENSE
README.md
Rakefile
struct-alias_member.gemspec

README.md

struct-alias_member

Description

Struct will be able to alias the members name.

Usage

Overview

require 'struct/alias_member'

BankAccount = Struct.new :name, :balance do
  alias_member :money, :balance
end

ac = BankAccount.new 'John', 100
ac.money          #=> 100
ac[:money]        #=> 100
ac[:money] = 999
ac.balance        #=> 999
ac.member? :money #=> true
ac.aliases        #=> {:money=>:balance}

Requirements

Install

$ gem install struct-alias_member

Build Status

Build Status

Link

License

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

Something went wrong with that request. Please try again.