Skip to content

Instantly share code, notes, and snippets.

View jeffrydegrande's full-sized avatar

Jeffry Degrande jeffrydegrande

View GitHub Profile
group :development, :test do
gem 'ruby-debug', :platforms => :ruby_18
gem 'ruby-debug19', :platforms => :ruby_19
end
require 'rubygems'
require 'test/unit'
require 'redgreen'
class Card
attr_reader :suite, :value
def initialize(options={})
@suite = options[:suite]
@value = options[:value]
like_this :when => "called",
:like => "this"
like_that(when, signature, is, like, this)
LANG=
LC_COLLATE="C"
LC_CTYPE="UTF-8"
LC_MESSAGES="C"
LC_MONETARY="C"
LC_NUMERIC="C"
LC_TIME="C"
LC_ALL=
class Company < ActiveRecord::Base
def update_with_password(params={})
if params[:password].blank?
params.delete(:password)
params.delete(:password_confirmation) if params[:password_confirmation].blank?
end
update_attributes(params)
end
ATTRIBUTES_ORDERED_FOR_CREATING_GUIDS = [:guid, :url, :content, :summary]
def self.guid_from_entry(entry)
def entry.can_make_guid_with?(symbol)
respond_to?(symbol) && send(symbol).present?
end
def entry.make_guid_from(symbol)
Digest::MD5.hexdigest(send(symbol))
end
ATTRIBUTES_ORDERED_FOR_CREATING_GUIDS.each do |symbol|
def self.guid_from_entry(entry)
def entry.available_for_guid?(sym)
respond_to?(sym) && send(sym).present?
end
[:guid, :url, :content, :summary].each do |sym|
entry.available_for_guid?(sym) and return Digest::MD5.hexdigest(entry.send(sym))
end
end
def self.guid_from_entry(entry)
[:guid, :url, :content, :summary].each do |sym|
entry.respond_to?(sym) and entry.send(sym).present? and return Digest::MD5.hexdigest(entry.send(sym))
end
end
def self.guid_from_entry(entry)
result = ''
[:guid, :url, :content, :summary].each do |sym|
next unless entry.respond_to?(sym) and entry.send(sym).present?
result = Digest::MD5.hexdigest(entry.send(sym))
break
end
result
end
def self.guid_from_entry(entry)
if entry.respond_to?(:guid) && entry.guid.present?
Digest::MD5.hexdigest(entry.guid.to_s)
elsif entry.respond_to?(:url) && entry.url.present?
Digest::MD5.hexdigest(entry.url.to_s)
elsif entry.respond_to?(:content) && entry.content.present?
Digest::MD5.hexdigest(entry.content.to_s)
else entry.respond_to?(:summary) && entry.summary.present?
Digest::MD5.hexdigest(entry.summary.to_s)
end