Skip to content

Commit

Permalink
parseLine: expose adminCode
Browse files Browse the repository at this point in the history
The admin code is often helpful to distinguish lines that can't
be distinguished by their `operator.id`. See also #10.
  • Loading branch information
derhuerst committed Mar 8, 2020
1 parent 3ea9380 commit 8c7f164
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 0 deletions.
4 changes: 4 additions & 0 deletions parse/line.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@ const parseLine = ({profile}, p) => {
// todo: what is p.number?
// todo: what is p.prodCtx.catCode?

if (p.prodCtx && 'string' === typeof p.prodCtx.admin) {
res.adminCode = p.prodCtx.admin.replace(/-+$/, '')
}

if ('cls' in p) {
// todo: use profile.products.find() for this
const byBitmask = []
Expand Down
1 change: 1 addition & 0 deletions test/fixtures/bvg-journey.js
Original file line number Diff line number Diff line change
Expand Up @@ -702,6 +702,7 @@ module.exports = {
id: 's-bahn-berlin-gmbh',
name: 'S-Bahn Berlin GmbH'
},
adminCode: 'DBS',
symbol: 'S',
nr: 2,
metro: false,
Expand Down
3 changes: 3 additions & 0 deletions test/fixtures/vbb-departures.js
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,7 @@ module.exports = [
fahrtNr: '19869',
name: 'U8',
public: true,
adminCode: 'BVU',
mode: 'train',
product: 'subway',
operator: {
Expand Down Expand Up @@ -854,6 +855,7 @@ module.exports = [
fahrtNr: '19453',
name: 'U8',
public: true,
adminCode: 'BVU',
mode: 'train',
product: 'subway',
operator: {
Expand Down Expand Up @@ -1612,6 +1614,7 @@ module.exports = [
fahrtNr: '27739',
name: 'S9',
public: true,
adminCode: 'DBS',
mode: 'train',
product: 'suburban',
operator: {
Expand Down

0 comments on commit 8c7f164

Please sign in to comment.