<commit_before># TaipeiEbus

Ruby gem for Taipei ebus API

## Installation

Add this line to your application's Gemfile:

    gem 'taipei_ebus'

And then execute:

    $ bundle

Or install it yourself as:

    $ gem install taipei_ebus

## Usage

usage instructions:
- the gem require 'nokogiri', please install it

##### taipei_ebus = TaipeiEbus::TaipeiEbus.new

- new an instance object

##### buslines = taipei_ebus.get_buslines

- to get a list of buslines
- the method will return a json array containing the following information: 
- [ { :title => "xxx", :rid => nnn, :url_id => n }, ... ]

- to get busline information
- the method will return a json object regarding this specific busline: 
- { :title => "xxx", :rid => nnn, :url_id => n }

##### busline = taipei_ebus.get_busline_info_by_title( busline_title, buslines )
##### busline = taipei_ebus.get_busline_info_by_title( busline_title )

- given parameter
- busline_title = buslines[0][:title] - or -
- busline_title = "241"

##### busline_stops = taipei_ebus.get_busline_stops( rid, url_id, direction )
##### busline_stops = taipei_ebus.get_busline_stops( rid, url_id )

- to get busline stops
- the method will return a json object: 
- { :go => [ { :idx => nn, :name => "xxx" }, ...], :back => [] }

- given parameter
- rid which is provided from method get_busline_info_by_title, example: busline[:rid]
- url_id which is provided from method get_busline_info_by_title, example: busline[:url_id]
- direction: value 0 or 1 or dismiss means query both {:go} and {:back} data if any

##### busline_update = taipei_ebus.get_busline_current_update( rid, url_id, direction )
##### busline_update = taipei_ebus.get_busline_current_update( rid, url_id )

- to get busline real-time update information
- the method will return a json object:
- { :go => { :Etas => [ { :idx => nn, :eta => nnn }, ...], 
- :Buses => [ { :bn => "xxx", :idx => nn, :fl => "x", :io => "x" }, ...] }, :back => {} }

##### taipei_ebus.parse_eta( eta )

- parse eta information
- the method return a string containing the meaning of eta
- eta can be get from busline_update as above

## Contributing

1. Fork it ( https://github.com/[my-github-username]/taipei_ebus/fork )
2. Create your feature branch (`git checkout -b my-new-feature`)
3. Commit your changes (`git commit -am 'Add some feature'`)
4. Push to the branch (`git push origin my-new-feature`)
5. Create a new Pull Request<commit_msg>update readme.md usage description<commit_after># TaipeiEbus

Ruby gem for Taipei ebus API

## Installation

Add this line to your application's Gemfile:

    gem 'taipei_ebus'

And then execute:

    $ bundle

Or install it yourself as:

    $ gem install taipei_ebus

## Usage

usage instructions:

You can see demo [here](http://cog101.herokuapp.com/myebus/jq).

> the gem require 'nokogiri', please install it

to new an instance object:

    taipei_ebus = TaipeiEbus::TaipeiEbus.new

to get a list of buslines:

    buslines = taipei_ebus.get_buslines

> the method will return a json array containing the following information: 
> - [ { :title => "xxx", :rid => nnn, :url_id => n }, ... ]

to get busline information by title: 

    busline = taipei_ebus.get_busline_info_by_title( busline_title, buslines )
    busline = taipei_ebus.get_busline_info_by_title( busline_title )

> the method will return a json object regarding this specific busline: 
> - { :title => "xxx", :rid => nnn, :url_id => n }

> given parameters:
> - busline_title: buslines[0][:title] or assign a string value, example: "241"
> - buslines: get from method 'get_buslines'

to get busline stops:

    busline_stops = taipei_ebus.get_busline_stops( rid, url_id, direction )
    busline_stops = taipei_ebus.get_busline_stops( rid, url_id )

> the method will return a json object: 
> - { :go => [ { :idx => nn, :name => "xxx" }, ...], :back => [] }

> given parameters:
> - rid which is provided from method 'get_busline_info_by_title', example: busline[:rid]
> - url_id which is provided from method 'get_busline_info_by_title', example: busline[:url_id]
> - direction: value 0 or 1, or dismiss means query both {:go} and {:back} data if any

to get busline real-time update information:

    busline_update = taipei_ebus.get_busline_current_update( rid, url_id, direction )
    busline_update = taipei_ebus.get_busline_current_update( rid, url_id )

> the method will return a json object:
> - { :go => { :Etas => [ { :idx => nn, :eta => nnn }, ...], :Buses => [ { :bn => "xxx", :idx => nn, :fl => "x", :io => "x" }, ...] }, :back => {} }

parse eta information:

    taipei_ebus.parse_eta( eta )

> the method return a string containing the meaning of eta

> eta can be get from 'busline_update' as above

## Contributing

1. Fork it ( https://github.com/[my-github-username]/taipei_ebus/fork )
2. Create your feature branch (`git checkout -b my-new-feature`)
3. Commit your changes (`git commit -am 'Add some feature'`)
4. Push to the branch (`git push origin my-new-feature`)
5. Create a new Pull Request
{'fraction_non_alphanumeric': 0.12938596491228072, 'fraction_numerical': 0.004984051036682616, 'mean_word_length': 3.957509881422925, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 61, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6752524', 'n_tokens_mistral': 1800, 'n_tokens_neox': 1694, 'n_words': 555}