Skip to content

Instantly share code, notes, and snippets.

@dreftymac
Last active December 20, 2015 02:39
Show Gist options
  • Save dreftymac/6057960 to your computer and use it in GitHub Desktop.
Save dreftymac/6057960 to your computer and use it in GitHub Desktop.
code library
### ------------------------------------------------------------------------
## {
module DreftymacQuikpayString
## {
module Base
## {
def str_is_not_valid
"__Invalid #{self.to_s}__"
end
## }
## {
## convert a quikpay transactionStatus integer into its human-readable description
def str_tstatus_english
icc = self.to_i.to_s;
dict = 'Status'
lookup = {
"1" => "ACCEPTED",
"2" => "REJECTED",
"3" => "UNKNOWN",
"4" => "ERROR",
"5" => "ACCEPTED",
"6" => "ACCEPTED",
"7" => "REJECTED",
"8" => "ACCEPTED",
}
vout = if (lookup[icc].to_s != ''); lookup[icc].to_s; else; dict.str_is_not_valid end;
return vout
end
## }
## {
## convert a quikpay transactionType integer into its human-readable description
def str_ttype_english
icc = self.to_i.to_s;
dict = 'Type'
lookup = {
"1" => "CC Payment",
"2" => "CC Refund",
"3" => "eCheck Payment",
}
vout = if (lookup[icc].to_s != ''); lookup[icc].to_s; else; dict.str_is_not_valid end;
return vout
end
## }
end
## }
end
## }
## {
class String
include DreftymacQuikpay::String
end
## }
### ------------------------------------------------------------------------
if (111!=0)
puts '### ------------------------------------------------------------------------'
( "0" .. "9" ).to_a.each {|item|
vout = []
vout << item.inspect;
vout << item.str_ttype_english.inspect + ","
puts vout.join(" => ")
}
puts '### ------------------------------------------------------------------------'
( "0" .. "9" ).to_a.each {|item|
vout = []
vout << item.inspect;
vout << item.str_tstatus_english.inspect + ","
puts vout.join(" => ")
}
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment