Skip to content

Instantly share code, notes, and snippets.

@Ross-Hunter
Last active August 29, 2015 14:00
Show Gist options
  • Save Ross-Hunter/11144996 to your computer and use it in GitHub Desktop.
Save Ross-Hunter/11144996 to your computer and use it in GitHub Desktop.
## Contrived Example
# Will the thing float?
class Thing
attr_accessor :mass, :volume
def will_i_float?
(mass / volume) < 1
end
end
# vs
class Thing
attr_accessor :mass, :volume
def will_i_float?
density < density_of_water
end
def density
mass / volume
end
def density_of_water
1 # g/mL
end
end
## End Contrived Example
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment