Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

module Echoer
def echoes(*phrases)
@known_phrases.concat(phrases)
@known_phrases.each do |phrase|
next if self.respond_to?(phrase.to_sym)
define_method("#{phrase}") { phrase.to_s }
end
end
@jpmoral
jpmoral / modules.rb
Created July 21, 2015 11:38
extend vs. include in spec form
module Motion
def default_movement
"walking"
end
end
module Flight
extend Motion
def movement
module StringLookup
def self.lookup(string)
case string
when /^Foo.*$/ then 'group A'
when /^F.*$/ then 'group B'
when /^Bar.*$/ then 'group C'
when /^Baz.*$/ then string.gsub('a', '0')
end
end
require 'sinatra/base'
class GetServer < Sinatra::Base
set :logging, nil
get '/' do
puts "count: #{params["request_number"]}"
end
end