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.
benchmarks Clean up trailing whitespace
examples
lib Bump to 0.0.4.1
test Remove verbose $VERBOSE flag :)
.gitignore Clean up trailing whitespace
.travis.yml Update Travis-CI settings
.yardopts Add YARD settings
Gemfile Improve Gemfile
MIT-LICENSE Cleafy license summary at file name
README.md Fix URI of Homepage
Rakefile Clean up trailing whitespace
flyweight.gemspec Fix URI of Homepage

README.md

flyweight

Build Status Gem Version

Description

A tiny template for the "Flyweight Pattern".

Features

  • MyClass.intern

Usage

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

Install

$ gem install flyweight

Link

License

The MIT X11 License
Copyright (c) 2012 Kenichi Kamiya
See MIT-LICENSE for further details.

Something went wrong with that request. Please try again.