Skip to content

Instantly share code, notes, and snippets.

@rklemme
rklemme / respond_to_vs_include.rb
Last active December 15, 2015 17:49
Modified version which compares the single method check times (which need to include Mock.instance_methods(false)).
# Fancy benchmark...
# is respond_to? so faster than include?
require 'benchmark'
n = 10_000_000
mock_methods = ('a'..'z').to_a
class Mock
end
# Fancy benchmark...
# is respond_to? so faster than include?
require 'benchmark'
n = 10_000_000
mock_methods = ('a'..'z').to_a
class Mock
end
@rklemme
rklemme / phrase_splitter.rb
Created June 6, 2011 14:12 — forked from thehack/phrase_splitter.rb
(fork) I'm trying to split a phrase into 6 or less rows of 12 or less letters each.
LEN = 60
LIMIT = 12
phrase = nil
begin
puts "Enter phrase. #{LEN} characters or less."
phrase = gets.chomp
end while phrase.length > LEN