Skip to content
A tiny template for the “Flyweight Pattern”
Ruby
Find file
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.
example
lib
test
.gitignore
History.rdoc
LICENSE
Manifest.txt
README.rdoc
Rakefile

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

    target release versions

    • 1.9.3-p125

    • 1.9.2-p290

Installation

  • gem install flyweight

License

Copyright (C) 2012 Kenichi Kamiya

The MIT/X11 License (See the file LICENSE)

Something went wrong with that request. Please try again.