package app.vo { import mx.collections.ArrayCollection; [Bindable] public class Ride extends Entity { public var bikeId:int; public var routeId:int; public var startTimestamp:Date; public var mileage:Number; public var timeElapsed:uint; public var maximumSpeed:Number; public var notes:String; public var bike:Bike; public var route:Route; public var stopList:ArrayCollection = new ArrayCollection(); private var _stopCount:int; public function get stopCount():int { if (stopList == null || stopList.length == 0) { return _stopCount; } else { return stopList.length; } } public function set stopCount(i:int):void { _stopCount = i; } public function get averageSpeed():Number { return mileage / timeElapsed * 3600; } public function Ride(state:*=null) { super(state); } public override function initialize(state:*):void { super.initialize(state); if (state != null) { this.bikeId = state.bikeId; this.routeId = state.routeId; this.startTimestamp = state.startTimestamp; this.mileage = state.mileage; this.timeElapsed = state.timeElapsed; this.maximumSpeed = state.maximumSpeed; this.notes = state.notes; this.stopCount = state.stopCount; } } public function toString():String { return (route == null ? "Route " + routeId : route.name) + " at " + startTimestamp + " (" + id + ")"; } } }