Favorite

Favorite

RT Favorite

Representation of a Right Track User Favorite. This can be a saved Station, Trip or Train with the associated parameters and optional options.

The following describes the format for the Favorite parameters and options.

Station

Parameters:

 {
   stop: {
     id: 'Stop ID',
     name: 'Stop Name'
   }
 }

Options:

Currently, there are no options for a Favorite Station.

Trip

Parameters:

 {
   origin: {
     id: 'Stop ID'
     name: 'Stop Name'
   },
   destination: {
     id 'Stop ID'
     name: 'Stop Name'
   }
 }

Options:

 {
   allowTransfers: true
 }

Module: rt/Favorite

Constructor

new Favorite(type, sequence, parameters, optionsopt)

Source:

Create a new Favorite with the specified information

Parameters:
Name Type Attributes Default Description
type int

Favorite Type

sequence int

Favorite Sequence (1, 2, etc...)

parameters Object

Favorite Station or Trip Parameters

options Object <optional>
{}

Favorite Station or Trip Options

Members

(static, constant) FAVORITE_TYPE_STATION :number

Source:
Default Value:
  • 1

Favorite Type: Station

Type:
  • number

(static, constant) FAVORITE_TYPE_TRIP :number

Source:
Default Value:
  • 2

Favorite Type: Trip

Type:
  • number

options :Object

Source:

The Favorite's Options

Type:
  • Object

parameters :Object

Source:

The Favorite's Parameters

Type:
  • Object

sequence :int

Source:

The sequence of the Favorite in the User's list

Type:
  • int

type :int

Source:

Value indicating the Favorite type

Type:
  • int

Methods

(static) createStation(stop, sequence, optsopt) → {Favorite}

Source:

Favorite Factory: create a Favorite Station

Parameters:
Name Type Attributes Default Description
stop Stop

The Stop to save as a Favorite Station

sequence int

The Favorite sequence

opts Object <optional>
{}

Station Options

Returns:

Favorite Station

Type
Favorite

(static) createTrip(origin, destination, sequence, optsopt) → {Favorite}

Source:

Favorite Factory: create a Favorite Trip

Parameters:
Name Type Attributes Default Description
origin Stop

The origin of the Favorite Trip

destination Stop

The destination of the Favorite Trip

sequence int

The Favorite sequence

opts Object <optional>
{}

Trip Options

Returns:

Favorite Trip

Type
Favorite

(static) sortBySequence(a, b) → {number}

Source:

Sort Favorites by sequence (ascending)

Parameters:
Name Type Description
a Favorite

first Favorite

b Favorite

second Favorite

Returns:

compare integer

Type
number

isStation() → {boolean}

Source:

Check if the Favorite is a Favorite Station

Returns:

true if Station

Type
boolean

isTrip() → {boolean}

Source:

Check if the Favorite is a Favorite Trip

Returns:

true if Trip

Type
boolean

Type Definitions

FavoriteStationOptions

Source:

The Options for a Favorite Station

Type:
  • Object

FavoriteStationParameters

Source:
Properties:
Name Type Description
stop

The Favorite Station

Properties
Name Type Description
id

Stop Id

name

Stop Name

The Parameters for a Favorite Station

Type:
  • Object

FavoriteTripOptions

Source:
Properties:
Name Type Description
allowTransfers boolean

Allow the Trip Result to include transfers

The Options for a Favorite Trip

Type:
  • Object

FavoriteTripParameters

Source:
Properties:
Name Type Description
origin

The Origin Stop

Properties
Name Type Description
id

Origin Id

name

Origin Name

destination

The Destination Stop

Properties
Name Type Description
id

Destination Id

name

Destination Name

The Parameters for a Favorite Trip

Type:
  • Object