Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

@trip_id returns nil #17

Open
muit opened this issue Aug 3, 2014 · 2 comments
Open

@trip_id returns nil #17

muit opened this issue Aug 3, 2014 · 2 comments

Comments

@muit
Copy link

muit commented Aug 3, 2014

The variable trip_id from stop_times comes nil everytime its called.

I dont know why, because the content of the class is:

<GTFS::StopTime:0x99bffc4 @trip_id="SA00100310", @arrival_time="13:19:00", @departure_time="13:19:00", @stop_id="4514", @stop_sequence="1", @stop_headsign=nil, @pickup_type=nil, @drop_off_type=nil, @shape_dist_traveled="0">

And row.trip_id returns 'nil'

@muit
Copy link
Author

muit commented Aug 6, 2014

The problem comes when reading a UTF-8 BOM, because it contains "\xEF\xBB\xBF".

@trip_id will be declared as "@\xEF\xBB\xBFtrip_id".

"#<GTFS::StopTime:0x8b9a638 @\xEF\xBB\xBFtrip_id=\"FE00100317\", @arrival_time=\"17:37:44\", @departure_time=\"17:37:44\", @stop_id=\"168\", @stop_sequence=\"19\", @stop_headsign=nil, @pickup_type=nil, @drop_off_type=nil, @shape_dist_traveled=\"6183\">"

should be

"#<GTFS::StopTime:0x8b9a638 @trip_id=\"FE00100317\", @arrival_time=\"17:37:44\", @departure_time=\"17:37:44\", @stop_id=\"168\", @stop_sequence=\"19\", @stop_headsign=nil, @pickup_type=nil, @drop_off_type=nil, @shape_dist_traveled=\"6183\">"

I fixed it for my self replacing the method initialize from Model whit:

attrs.each do |key, val|
    realkey = key.gsub("\xEF\xBB\xBF".force_encoding("UTF-8"), "")
    instance_variable_set("@#{realkey}", val)
end

(I know it sucks)

@nerdEd
Copy link
Owner

nerdEd commented Aug 12, 2014

Thanks for the bug report @muit! Sorry for the late reply, I was on vacation when you reported the issue and I'm just catching up.

Happily you seem to have found a workaround for the time being. I'll try and find some time in the near future to look at this more closely... but until then if you come across any solutions your happy with I'd happily accept pull requests (with passing tests) and cut a new release on rubygems.

Thanks again!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants