Skip to content

Instantly share code, notes, and snippets.

@shepmaster
Created November 7, 2012 22:15
Show Gist options
  • Select an option

  • Save shepmaster/4034868 to your computer and use it in GitHub Desktop.

Select an option

Save shepmaster/4034868 to your computer and use it in GitHub Desktop.
def round_to(num, places) # Pass in both parameters
(num * 10 ** places).round.to_f / 10 ** places
end
def ftoc(num)
answerc = ((num - 32) / 1.8)
puts "ftoc spits out #{self.class}"
round_to(answerc, 1)
end
def ctof(num)
answerf = ((num - 32) / 1.8)
puts "ctof spits out #{self.class}" # can use #{} to insert strings
round_to(answerf, 1) # no need to say `return` on the last line
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment