Created
September 11, 2012 21:12
-
-
Save lenagroeger/3702094 to your computer and use it in GitHub Desktop.
fmt_stat for fracking
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def fmt_stat(stat, prefix = stat > 0 ? "$" : "") | |
stat = case stat | |
when -999999999999..-10000 then number_to_human(stat, :units => {:million => "M", :thousand => "K", :billion => "B"}).gsub(/ /,'') | |
when -9999..-1 then number_with_delimiter(stat) | |
when 0 then "<em>No Data.</em>" | |
when 1..9999 then number_with_delimiter(stat) | |
when 10000..999999999999 then number_to_human(stat, :units => {:million => "M", :thousand => "K", :billion => "B"}).gsub(/ /,'') | |
when nil then number_with_delimiter(0) | |
else stat | |
end | |
stat = stat === "N/A" ? stat : "#{prefix}#{stat}" | |
end | |
def format(sym) | |
money = [:staff_budget, :oil_and_gas_department_budget] | |
integers = Field.bolded - money | |
per = [:total_wells] | |
return case | |
when money.include?(sym) then | |
fmt_stat(send(sym).to_f) | |
when integers.include?(sym) then | |
number_with_delimiter(send(sym)) | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment