Skip to content

Instantly share code, notes, and snippets.

module Printable
def print
end
def prepare_cover
end
end
module Document
def print_to_screen
class A
instance_methods.each do |m|
undef_method m unless m.to_s =~ /^__|object_id|method_missing|respond_to?/
end
def initialize(o)
@o = o
end
def method_missing(name, *args)
lambda {
setups = []
events = {}
Kernel.send :define_method, :event do |name, &block|
events[name] = block
end
Kernel.send :define_method, :setup do |&block|
setups << block
class Book
def title(title)
puts title
end
def self.deprecate(old_method, new_method)
define_method(old_method) do |*args, &block|
warn "Warning: #{old_method}() is deprecated. Use #{new_method}()."
send(new_method, *args, &block)
end
p "てすと"
#!/usr/bin/env ruby
# coding: utf-8
class Report
def initialize
@title = "月次報告"
@text = ["順調","最高の調子"]
end
def output_report
# usage rake new_post[my-new-post] or rake new_post['my new post'] or rake new_post (defaults to "new-post")
desc "Begin a new post in #{source_dir}/#{posts_dir}"
task :new_post, :title do |t, args|
raise "### You haven't set anything up yet. First run `rake install` to set up an Octopress theme." unless File.directory?(source_dir)
mkdir_p "#{source_dir}/#{posts_dir}"
args.with_defaults(:title => "■")
title = args.title
index = 1
while File.exist?("#{source_dir}/#{posts_dir}/#{Time.now.strftime('%Y-%m-%d')}-#{index}.#{new_post_ext}")
#!/usr/bin/env ruby
# coding: utf-8
class Report
attr_reader :title, :text
attr_accessor :formatter
def initialize(&formatter)
@title = "月次報告"
@text = ["順調","最高の調子"]
#!/usr/bin/env ruby
# coding: utf-8
module Subject
def initialize
@observers = []
end
def add_observer(&observer)
@observers << observer
#!/usr/bin/env ruby
# conding: utf-8
class Task
attr_reader :name
def initialize(name)
@name = name
end