question.rb
solution.rb
playground.rb
1 require_relative "../physics" 2 3 question :weighing_the_earth_by_its_pull do 4 kind :numerical 5 describes "Weighing the Earth: you are given g = %{gravity} at the Earth's surface and the Earth's radius " \ 6 "%{radius}. %{mass}, in kg?" 7 given gravity: "9.81 m/s2" 8 given radius: "6.37e6 m" 9 asks mass: "What is the mass of the Earth" 10 end
1 require_relative "../questions/weighing_the_earth_by_its_pull" 2 require_relative "../science/gravitation/universal_gravitation" 3 4 solve :weighing_the_earth_by_its_pull , using: UniversalGravitation do 5 objects :earth 6 7 take gravity: earth . surface_gravity 8 take radius: earth . radius_of_the_body 9 10 mass = earth . mass 11 answer mass :, in: "kg" , figures: 3 12 13 conclusion "How hard the Earth pulls at its surface depends only on its mass and how far the surface " \ 14 "is from its centre, so the pull and the radius give the mass." 15 end
1 require_relative "../solutions/weighing_the_earth_by_its_pull" 2 3 play_with :weighing_the_earth_by_its_pull do 4 title "Weighing the Earth by Its Pull" 5 end