This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Printable | |
def print | |
end | |
def prepare_cover | |
end | |
end | |
module Document | |
def print_to_screen |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
lambda { | |
setups = [] | |
events = {} | |
Kernel.send :define_method, :event do |name, &block| | |
events[name] = block | |
end | |
Kernel.send :define_method, :setup do |&block| | |
setups << block |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
p "てすと" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
# coding: utf-8 | |
class Report | |
def initialize | |
@title = "月次報告" | |
@text = ["順調","最高の調子"] | |
end | |
def output_report |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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}") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
# coding: utf-8 | |
class Report | |
attr_reader :title, :text | |
attr_accessor :formatter | |
def initialize(&formatter) | |
@title = "月次報告" | |
@text = ["順調","最高の調子"] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
# coding: utf-8 | |
module Subject | |
def initialize | |
@observers = [] | |
end | |
def add_observer(&observer) | |
@observers << observer |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
# conding: utf-8 | |
class Task | |
attr_reader :name | |
def initialize(name) | |
@name = name | |
end |
OlderNewer