Class: Translink::CLI

Inherits:
Object
  • Object
show all
Defined in:
lib/translink/cli.rb

Constant Summary collapse

RUNNABLE =
['help', 'scrape', 'version']
URL =
'http://jp.translink.com.au/travel-information/network-information/buses/all-timetables'

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(pwd) ⇒ CLI

Returns a new instance of CLI.



8
9
10
11
12
# File 'lib/translink/cli.rb', line 8

def initialize pwd
  self.__crawler__ = Translink::Crawler
  self.out         = $stdout
  self.pwd         = pwd
end

Instance Attribute Details

#__crawler__Object

Returns the value of attribute __crawler__.



6
7
8
# File 'lib/translink/cli.rb', line 6

def __crawler__
  @__crawler__
end

#outObject

Returns the value of attribute out.



6
7
8
# File 'lib/translink/cli.rb', line 6

def out
  @out
end

#pwdObject

Returns the value of attribute pwd.



6
7
8
# File 'lib/translink/cli.rb', line 6

def pwd
  @pwd
end

Instance Method Details

#run(line) ⇒ Object



14
15
16
17
18
19
20
21
# File 'lib/translink/cli.rb', line 14

def run line
  command, input = line.split /\s/, 2
  if RUNNABLE.include? command
    send command, input
  else
    help nil
  end
end