Skip to content
This repository

A tiny template for the “Flyweight Pattern”

tree: e18353c1f6

Fetching latest commit…

Octocat-spinner-32-eaf2f5

Cannot retrieve the latest commit at this time

Octocat-spinner-32 benchmarks
Octocat-spinner-32 examples
Octocat-spinner-32 lib
Octocat-spinner-32 test
Octocat-spinner-32 .gitignore
Octocat-spinner-32 .travis.yml
Octocat-spinner-32 Gemfile
Octocat-spinner-32 History.rdoc
Octocat-spinner-32 LICENSE
Octocat-spinner-32 Manifest.txt
Octocat-spinner-32 README.rdoc
Octocat-spinner-32 Rakefile
Octocat-spinner-32 flyweight.gemspec
README.rdoc

Flyweight

Description

A tiny template for the “Flyweight Pattern”.

Usage

  • Setup

    require 'flyweight'
  • Overview

    class Material
      include Flyweight
    
      def initialize(looks, price)
        @looks, @price = looks, price
      end
    end
    
    a = Material.intern :metal, 2000
    b = Material.intern :metal, 2000
    c = Material.new    :metal, 2000
    d = Material.intern :paper, 50
    a == b     #=> true
    a.equal? b #=> true
    a == c     #=> true
    a.equal? c #=> false
    a == d     #=> false
    a.equal? d #=> false

Requirements

  • Ruby 1.9.2 or later

Installation

gem install flyweight

Links

code

github.com/kachick/flyweight

issues

github.com/kachick/flyweight/issues

CI

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

gem

rubygems.org/gems/flyweight

gem+

metagem.info/gems/flyweight

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.