Created
December 7, 2011 17:43
-
-
Save zackham/1443771 to your computer and use it in GitHub Desktop.
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
ruby-1.9.2-p290 :019 > a.course_points | |
=> [{"x"=>-123.09956999999997, "y"=>43.99689, "t"=>"Left", "n"=>"Skarpt til venstre og inn på Willamette St", "d"=>1558.2270196996717, "i"=>45}, {"x"=>-123.09476000000001, "y"=>44.00251, "t"=>"Right", "n"=>"Sving til høyre og inn på Coachman Dr", "d"=>2319.6279202483624, "i"=>-1}, {"x"=>-123.0924, "y"=>44.00288, "t"=>"Right", "n"=>"Ta til høyre mot E 49th Ave", "d"=>2561.46875989974, "i"=>89}, {"x"=>-123.09163999999998, "y"=>44.00336, "t"=>"Right", "n"=>"Sving til høyre og inn på E 49th Ave", "d"=>2642.4525533428578, "i"=>92}, {"x"=>-123.08988999999997, "y"=>44.00312, "t"=>"Right", "n"=>"Sving til høyre og inn på Donald St", "d"=>2791.013780653592, "i"=>100}, {"x"=>-123.09055999999998, "y"=>44.00058000000001, "t"=>"Right", "n"=>"Sving til høyre og inn på Ventura Ave", "d"=>3084.1878589167495, "i"=>116}] | |
ruby-1.9.2-p290 :020 > new_cps = a.course_points.map{|cp| new_cp = cp.clone ; new_cp['n'] = 'probably gotta clone otherwise it modifies the original too'; new_cp} => [{"x"=>-123.09956999999997, "y"=>43.99689, "t"=>"Left", "n"=>"probably gotta clone otherwise it modifies the original too", "d"=>1558.2270196996717, "i"=>45}, {"x"=>-123.09476000000001, "y"=>44.00251, "t"=>"Right", "n"=>"probably gotta clone otherwise it modifies the original too", "d"=>2319.6279202483624, "i"=>-1}, {"x"=>-123.0924, "y"=>44.00288, "t"=>"Right", "n"=>"probably gotta clone otherwise it modifies the original too", "d"=>2561.46875989974, "i"=>89}, {"x"=>-123.09163999999998, "y"=>44.00336, "t"=>"Right", "n"=>"probably gotta clone otherwise it modifies the original too", "d"=>2642.4525533428578, "i"=>92}, {"x"=>-123.08988999999997, "y"=>44.00312, "t"=>"Right", "n"=>"probably gotta clone otherwise it modifies the original too", "d"=>2791.013780653592, "i"=>100}, {"x"=>-123.09055999999998, "y"=>44.00058000000001, "t"=>"Right", "n"=>"probably gotta clone otherwise it modifies the original too", "d"=>3084.1878589167495, "i"=>116}] | |
ruby-1.9.2-p290 :021 > a.course_points | |
=> [{"x"=>-123.09956999999997, "y"=>43.99689, "t"=>"Left", "n"=>"Skarpt til venstre og inn på Willamette St", "d"=>1558.2270196996717, "i"=>45}, {"x"=>-123.09476000000001, "y"=>44.00251, "t"=>"Right", "n"=>"Sving til høyre og inn på Coachman Dr", "d"=>2319.6279202483624, "i"=>-1}, {"x"=>-123.0924, "y"=>44.00288, "t"=>"Right", "n"=>"Ta til høyre mot E 49th Ave", "d"=>2561.46875989974, "i"=>89}, {"x"=>-123.09163999999998, "y"=>44.00336, "t"=>"Right", "n"=>"Sving til høyre og inn på E 49th Ave", "d"=>2642.4525533428578, "i"=>92}, {"x"=>-123.08988999999997, "y"=>44.00312, "t"=>"Right", "n"=>"Sving til høyre og inn på Donald St", "d"=>2791.013780653592, "i"=>100}, {"x"=>-123.09055999999998, "y"=>44.00058000000001, "t"=>"Right", "n"=>"Sving til høyre og inn på Ventura Ave", "d"=>3084.1878589167495, "i"=>116}] | |
ruby-1.9.2-p290 :022 > a.course_points = new_cps | |
=> [{"x"=>-123.09956999999997, "y"=>43.99689, "t"=>"Left", "n"=>"probably gotta clone otherwise it modifies the original too", "d"=>1558.2270196996717, "i"=>45}, {"x"=>-123.09476000000001, "y"=>44.00251, "t"=>"Right", "n"=>"probably gotta clone otherwise it modifies the original too", "d"=>2319.6279202483624, "i"=>-1}, {"x"=>-123.0924, "y"=>44.00288, "t"=>"Right", "n"=>"probably gotta clone otherwise it modifies the original too", "d"=>2561.46875989974, "i"=>89}, {"x"=>-123.09163999999998, "y"=>44.00336, "t"=>"Right", "n"=>"probably gotta clone otherwise it modifies the original too", "d"=>2642.4525533428578, "i"=>92}, {"x"=>-123.08988999999997, "y"=>44.00312, "t"=>"Right", "n"=>"probably gotta clone otherwise it modifies the original too", "d"=>2791.013780653592, "i"=>100}, {"x"=>-123.09055999999998, "y"=>44.00058000000001, "t"=>"Right", "n"=>"probably gotta clone otherwise it modifies the original too", "d"=>3084.1878589167495, "i"=>116}] | |
ruby-1.9.2-p290 :023 > a.save | |
=> true | |
ruby-1.9.2-p290 :024 > a.reload.course_points | |
=> [{"x"=>-123.09956999999997, "y"=>43.99689, "t"=>"Left", "n"=>"probably gotta clone otherwise it modifies the original too", "d"=>1558.2270196996717, "i"=>45}, {"x"=>-123.09476000000001, "y"=>44.00251, "t"=>"Right", "n"=>"probably gotta clone otherwise it modifies the original too", "d"=>2319.6279202483624, "i"=>-1}, {"x"=>-123.0924, "y"=>44.00288, "t"=>"Right", "n"=>"probably gotta clone otherwise it modifies the original too", "d"=>2561.46875989974, "i"=>89}, {"x"=>-123.09163999999998, "y"=>44.00336, "t"=>"Right", "n"=>"probably gotta clone otherwise it modifies the original too", "d"=>2642.4525533428578, "i"=>92}, {"x"=>-123.08988999999997, "y"=>44.00312, "t"=>"Right", "n"=>"probably gotta clone otherwise it modifies the original too", "d"=>2791.013780653592, "i"=>100}, {"x"=>-123.09055999999998, "y"=>44.00058000000001, "t"=>"Right", "n"=>"probably gotta clone otherwise it modifies the original too", "d"=>3084.1878589167495, "i"=>116}] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment