Skip to content

Instantly share code, notes, and snippets.

View practicingruby's full-sized avatar

Gregory Brown practicingruby

View GitHub Profile
class Bot
def initialize(parts)
add_parts(parts)
setup
end
def add_parts(parts)
parts.each { |part| extend(part) }
end
class MyEnumerator
include Enumerable
def initialize(target, *iterator)
@target = target
@iterator = iterator
end
def each(&block)
class MyEnumerator
include Enumerable
def initialize(target, *iterator)
@target = target
@iterator = iterator
end
def each(&block)
@target.send(*@iterator, &block)
@practicingruby
practicingruby / gist:1232567
Created September 21, 2011 16:34 — forked from stevemorris/gist:1232537
Circuitry
module Circuitry
extend self
def []=(name, definition)
circuits[name] = definition
end
def [](name)
circuits[name]
end
seacreature:~$ rvm 1.8.7
seacreature:~$ irb
>> if true: true end
=> true
>> exit
seacreature:~$ rvm 1.9.2
seacreature:~$ irb
>> if true: true end
SyntaxError: (irb):1: syntax error, unexpected ':', expecting keyword_then or ';' or '\n'
if true: true end
186 XML.ri
187 Test.ri
191 RbConfig.ri
197 XMLEncoding_ja.ri
198 Data.ri
203 RDocTask.ri
204 DefaultKey.ri
210 GDBMError.ri
210 SDBMError.ri
211 GDBMFatalError.ri
singleton Logger
def output
@output ||= STDOUT
end
attr_writer :output
def log(text)
output.puts(text)
end
>> class NotAProc
>> def call
>> puts "YES"
>> end
>> end
=> nil
>> NotAProc.new.()
YES
require "open3"
working_dir = File.dirname(__FILE__)
gettysburg_file = "#{working_dir}/data/gettysburg.txt"
spaced_file = "#{working_dir}/data/spaced_out.txt"
############################################################################
cat_output = `cat #{gettysburg_file}`
rcat_output = `rcat #{gettysburg_file}`