Skip to content

Instantly share code, notes, and snippets.

View adamgamble's full-sized avatar

Adam Gamble adamgamble

View GitHub Profile
require 'spec_helper'
describe TellerIncentiveReport do
before(:all) do
teller1 = flexmock(User.new)
teller2 = flexmock(User.new)
teller3 = flexmock(User.new)
teller4 = flexmock(User.new)
def makeProgress(i, t)
percent = (Float(i) / Float(t)) * 100
percent = (( percent / 5).round * 5).to_i
number_of_bars = percent / 5
progress = ""
for g in 0..number_of_bars do
progress = progress + "="
end
progress = progress + percent.to_s + "%"
for s in 0..(20 - number_of_bars) do
module Enumerable
def each_with_progress(&block)
self.each_with_index do |thing,i|
puts makeProgress(i,self.count)
block.call thing
end
nil
end
protected
module Enumerable
def each_with_progress(&block)
out = STDERR
self.each_with_index do |thing,i|
out.print sprintf("%s", makeProgress(i,self.count)) + "\r"
block.call thing
end
nil
end
options = {"DOB"=>"2000-01-01",
"ValidationQuestion"=>"what is 1 + blue",
"PostalRegion"=>"AL",
"PostalCity"=>"Birmingham",
"IDValue"=>7013088,
"SSN"=>"444-44-4444",
"IDType"=>1,
:pngUser=>
{:UserName=>"isotope", :APIKey=>"isotope", :Status=>true, :IsLocked=>false},
"LastName"=>"Gamble",
insert_sql << "INSERT INTO negative_balance_reports (bank, agent, store_number, name, ssn, pan, overdraft, their_balance, our_balance, overdraft_limit, account_type) VALUES "
@rows.each do |row|
insert_sql << "('#{@bank}', '#{row[0]}', '#{row[1]}', '#{row[2].gsub("'","''")}', '#{row[3]}', '#{row[4]}', '#{row[5]}', '#{row[6]}', '#{row[7]}', '#{row[8] == "N/A" ? 0 : row[8]}', '#{row[9]}'),"
end
NegativeBalanceReport.connection.execute(insert_sql.string.chop + ";")
if transaction_feed.is_pin? && transaction_feed.card.card_account.fee_plan == "Monthly Fee"
pin_fee_amount = BigDecimal(transaction_feed.card.store.region.region_setting[:settings]["monthly_plan_pin_fee"])
current_balance -= pin_fee_amount
end
if transaction_feed.is_pin? && transaction_feed.card.card_account.fee_plan == "Pay as you go"
pin_fee_amount = BigDecimal(transaction_feed.card.store.region.region_setting[:settings]["pay_as_you_go_pin_fee"])
current_balance -= pin_fee_amount
end
class Person < ActiveRecord::Base
named_scope hair_color, lambda { |hair_color| { :conditions => ["people.hair_color = ?", hair_color]}}
named_scope enjoys_chunky_bacon, lambda { |chunky_bacon_preference| {:conditions => ["people.chunky_bacon_preference = ?", chunky_bacon_prefence]}}
named_scope age_between, lambda { |lower_limit, upper_limit| {:conditions => ["people.age BETWEEN ? AND ?", lower_limit, upper_limit]}}
end
def search
bucket = Person
#Narrow our query depending on params sent
bucket = bucket.hair_color(params["hair_color"]) unless params["hair_color"].blank?
bucket = bucket.enjoys_chunky_bacon(params["chunky_bacon_preference"]) unless params["chunky_bacon_preference"].blank?
bucket = bucket.age_between(params["age_lower_limit"], params["age_upper_limit"]) unless params["age_lower_limit"].blank? && params["age_upper_limit"].blank?
#This actually does the query, if no params were sent then all people will be returned.
@people = bucket.all
>> str = "Snakes on a plane"
=> "Snakes on a plane"
>> str["Snakes"] = "Farts"
=> "Farts"
>> puts str
Farts on a plane