Skip to content

Instantly share code, notes, and snippets.

JP Moral jpmoral

Block or report user

Report or block jpmoral

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View class_instance_variables_and_inheritance.rb
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 Jul 21, 2015
extend vs. include in spec form
View modules.rb
module Motion
def default_movement
"walking"
end
end
module Flight
extend Motion
def movement
View string_lookup_case.rb
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
View server.rb
require 'sinatra/base'
class GetServer < Sinatra::Base
set :logging, nil
get '/' do
puts "count: #{params["request_number"]}"
end
end
You can’t perform that action at this time.