Ruby way for data serialization and simple postprocessing -


I'm still new to Ruby I have a model point and I need its serialized and processed data, I did it Code written:

  point = point.xx (: trachment). Where ('tracksegments.track_id' =>; track .id) .to_a prev_point = zero digits. Point | If prev_point! = Zero @fl_time + = point.point_created_at - prev_point.point_created_at @ points & lt; & Lt; {: Fl_time = & gt; Point.point_created_at - prev_point.point_created_at ,: fl_time_abs = & gt; Fl_time,: elevation_diff = & gt; (Prev_point.elevation - point.elevation). Round (2) ,: elevation = & gt; Point.elevation.round (2) ,: abs_altitude = & gt; Point.abs_altitude ,: Latitude = & gt; Point.latitude ,: Longitude = & gt; Point. Lame,: Distance = & gt; Point.distance.to_i ,: h_speed = & gt; Point.h_speed.round (2),: v_speed = & gt; Point.v_speed.round (2) ,: glrat = & gt; (Point.h_speed.round (2) / point.v_speed.round (2)). Round (2)} end prev_point = point end  

Is there any way to make it more compact and this amazing (true ruby ​​(or rail) way)?

I thought about the .map (and serilizable_hash) , but it does not symbolize the strings as the key.

In addition to this, I thought do each_proc (2). First, there is some thought about tax, , but it is some kind of converting, not only changes the current element of the array.


Comments