Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Struct like APIs
Ruby
tree: dde0c40ad3

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
declared
examples
lib
test
.gitignore
.travis.yml
Gemfile
History.rdoc
LICENSE
Manifest.txt
README.rdoc
Rakefile
structable.gemspec

README.rdoc

Structable

code

github.com/kachick/structable

bugs

github.com/kachick/structable/issues

Description

Provide APIs looks like “Struct”

Features

  • API looks Ruby's Struct

  • Member aliasing

  • Inheritable

Usage

Setup

require 'structable'

Overview

class Drink
  include Structable

  member :taste
end

class Tea < Drink
  member :leaf
  alias_member :type, :leaf
end

tea = Tea.new :bitter, :green
tea.members                          #=> [:taste, :leaf]
tea.members(true)                    #=> [:taste, :leaf, :type]
tea.member? :type                    #=> true
tea.type = 'Special Flavor'
tea.taste                            #=> :bitter
tea.leaf                             #=> 'Special Flavor'

Requirements

  • Ruby 1.9.2 or later

Installation

gem install structable

License

The MIT X License

Copyright (C) 2011-2012 Kenichi Kamiya

See the file LICENSE for further details.

Something went wrong with that request. Please try again.