Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Tag: structable-0.0…
Fetching contributors…

Cannot retrieve contributors at this time

59 lines (36 sloc) 1.014 kB

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.

Jump to Line
Something went wrong with that request. Please try again.