Skip to content

Instantly share code, notes, and snippets.

Created May 5, 2009 14:12
Show Gist options
  • Save anonymous/106983 to your computer and use it in GitHub Desktop.
Save anonymous/106983 to your computer and use it in GitHub Desktop.
Units = { :dollar_per_ffe => { :symbol => "$/ffe", :si_factor=>1.0 },
:dollar_per_ton => { :symbol => "$/T", :si_factor=>1.0e-3 }
}
Attribute_Units = { :default_transshipment_cost => :dollar_per_ffe,
:bunker_cost => :dollar_per_ton
}
def bunker_cost
read_attribute(:bunker_cost) / Units[Attribute_Units[:bunker_cost]][:si_factor];
end
def bunker_cost=(value)
write_attribute(:bunker_cost, value * Units[Attribute_Units[:bunker_cost]][:si_factor]);
end
def default_transshipment_cost
# as bunker_cost
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment