Skip to content
Find file
Fetching contributors…
Cannot retrieve contributors at this time
64 lines (40 sloc) 1.14 KB

Structable

Description

Provide API, looks “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

Links

code

github.com/kachick/structable

issues

github.com/kachick/structable/issues

CI

travis-ci.org/#!/kachick/structable

gem

rubygems.org/gems/structable

gem+

metagem.info/gems/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.