Unverified Commit f87220cf authored by Birte Kristina Friesel's avatar Birte Kristina Friesel
Browse files

Journey: Add type and number accessors

parent 41153346
Loading
Loading
Loading
Loading
+6 −1
Original line number Diff line number Diff line
@@ -10,7 +10,8 @@ use Travel::Status::DE::DBRIS::Location;

our $VERSION = '0.06';

Travel::Status::DE::DBRIS::Journey->mk_ro_accessors(qw(day train is_cancelled));
Travel::Status::DE::DBRIS::Journey->mk_ro_accessors(
	qw(day train type number is_cancelled));

sub new {
	my ( $obj, %opt ) = @_;
@@ -28,6 +29,10 @@ sub new {
		strptime_obj => $strptime,
	};

	# Number is either train no (ICE, RE) or line no (S, U, Bus, ...)
	# with no way of distinguishing between those
	( $ref->{type}, $ref->{number} ) = split( qr{\s+}, $ref->{train} );

	bless( $ref, $obj );

	for my $message ( @{ $json->{himMeldungen} // [] } ) {