Skip to content

Instantly share code, notes, and snippets.

View practicingruby's full-sized avatar

Gregory Brown practicingruby

View GitHub Profile
require "rubygems"
require "builder"
class Roster
def initialize
@members = []
@members_cache = []
@content = nil
end
class Foo
p self
class << self
def apples
"foo"
end
end
end
Fork this and add your example
Benchmark
CSV (Ruby 1.9, not 1.8!)
DRb
Delegator ## aguids
FileUtils ## tehviking
Fiber ## afcapel
JSON (The Ruby 1.9 stdlib, NOT the gems) ## sweetmango
Matrix ## morgy
MiniTest
OptionParser ## jazzu
class A
def self.extensions
@extensions ||= []
end
def self.run
@extensions.each do |klass|
klass.new.hello
end
end
Jul 07, 14:01:23
seacreature
I will be starting in 2 minutes, but please say hi now and mention your city :)
Jul 07, 14:01:24
locks
or we'd have the sessions up and running
Jul 07, 14:01:29
chrisdinn
JOINED
class Demo < Prawn::Document
def flower
0.step(270, 90) do |angle|
rotate(angle, :origin => [100, 100]) do
fill_color(random_color)
polygon [100, 100], [150, 150], [200, 100]
fill_and_stroke
end
end
end
module Prawn
module Chunkable
def chunk(*a, &b)
Prawn::Core::Chunk.new(*a, &b)
end
def find_chunks(params)
if params[:command]
chunks.select { |c| c.command == params[:command] }
end
module Prawn
class Canvas
include Prawn::Chunkable
def initialize
@chunks = []
end
attr_accessor :chunks
def paint(canvas, filename)
doc = Prawn::Document.new
doc.add_content(canvas.to_pdf)
doc.render_file(filename)
end
canvas = Prawn::Canvas.new
canvas.line(:point1 => [100,100], :point2 => [150,175])
canvas.move_to(:point => [100,100])
canvas.curve_to(:point => [50,50], :bounds => [[60,90], [60,90]])