Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Constant values for each instance.
Ruby
tree: c519e2b488

Fetching latest commit…

Cannot retrieve the latest commit at this time

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

README.rdoc

instancevalue

Description

Set constant values for each instance.

Usage

  • Setup

    require 'instancevalue'
  • Overview

    class Person
    
      include InstanceValue
    
      value_reader :birthday
    
      def initialize(birthday)
        val :birthday, birthday
      end
    
      def age
        (Time.now - birthday) / (60 * 60 * 24 * 365)
      end
    
    end
    
    person = Person.new Time.at YOUR_BIRTHDAY
    person.birthday                                 #=> YOUR_BIRTHDAY
    person.age                                      #=> age at runtime
    person.instance_eval{val :birthday, Time.now}   #=> Exception
  • It has instance_variable like API

    • .value_reader

    • #instance_value_defined?

    • #instance_value_get

    • #instance_value_set

    • #instance_values

    • #remove_instance_value

  • Aliased shortname

    • #val

Requirements

  • Ruby 1.9.2 or later

Installation

gem install instancevalue

Links

code

github.com/kachick/instancevalue

issues

github.com/kachick/instancevalue/issues

CI

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

gem

rubygems.org/gems/instancevalue

gem+

metagem.info/gems/instancevalue

License

The MIT X License

Copyright © 2012 Kenichi Kamiya

See the file LICENSE for further details.

Something went wrong with that request. Please try again.