Skip to content

Commit

Permalink
Updated readme
Browse files Browse the repository at this point in the history
  • Loading branch information
tusharmath committed Sep 7, 2013
1 parent 0a9c89f commit 11ce052
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 6 deletions.
6 changes: 6 additions & 0 deletions README.md
@@ -0,0 +1,6 @@
# pnr status
This is a simple console application which tells you about your [pnr status](http://www.indianrail.gov.in/pnr_Enq.html).

This app is different because it keeps making requests to the Indian Railway Servers so that it has the most up to date information. You don't manually have to check the status your self using this app.

Checkout [tusharmath.github.io](http://tusharmath.github.io/articles/pnr-status) for more information.
2 changes: 1 addition & 1 deletion lib/console-logger.coffee
Expand Up @@ -12,7 +12,7 @@ exports.log = _log = (pnrstatus) ->
#print pnrstatus
if pnrstatus.data.chart_prepared is true
clearl()
print 'Chart prepared.'
print '*** Chart prepared ***'

print ''
d = pnrstatus.data
Expand Down
4 changes: 2 additions & 2 deletions lib/index.coffee
Expand Up @@ -9,9 +9,9 @@ pnrNumber = Number argv._[0]

#Algorithms
onStatusRecieved = (status)->
pnrStatus.stop() if status.data.char_prepared is true
pnrStatus.stop() if status.data.chart_prepared is true
Logger.log status

pnrStatus = new Pnr pnrNumber, onStatusRecieved, 10
pnrStatus = new Pnr pnrNumber, onStatusRecieved
pnrStatus.start()

6 changes: 3 additions & 3 deletions lib/pnr-status.coffee
Expand Up @@ -5,21 +5,21 @@ print = console.log
class PnrStatus
constructor: (@pnr=8216477093, @callback, @interval=30*60*1000) ->
@url = "http://pnrapi.alagu.net/api/v1.0/pnr/#{@pnr}"
@stop = false
@continue = true

start: ->
me = @
http.get me.url,
(response) -> response.on 'data',
(buffer) ->
(->
if @stop is false
if @continue is true
@timer = setTimeout (-> me.start()), @interval
@callback JSON.parse buffer.toString()
).call me

stop: ->
@stop = true
@continue = false
clearTimeout @timer

module.exports = PnrStatus

0 comments on commit 11ce052

Please sign in to comment.