Class: USaidWat::Application::Command

Inherits:
Object
  • Object
show all
Includes:
Pager, Sysexits
Defined in:
lib/usaidwat/command.rb

Direct Known Subclasses

Info, Log, Posts, Tally, Timeline

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Pager

#page

Constructor Details

#initialize(prog) ⇒ Command

Returns a new instance of Command.



26
27
28
29
# File 'lib/usaidwat/command.rb', line 26

def initialize(prog)
  @client = cucumber? ? USaidWat::Client::TestRedditor : USaidWat::Client::Redditor
  Timecop.freeze(Time.parse(ENV['USAIDWAT_CURRENT_TIME'])) if cucumber_time?
end

Instance Attribute Details

#clientObject (readonly)

Returns the value of attribute client.



13
14
15
# File 'lib/usaidwat/command.rb', line 13

def client
  @client
end

Class Method Details

.inherited(base) ⇒ Object



20
21
22
23
# File 'lib/usaidwat/command.rb', line 20

def inherited(base)
  subclasses << base
  super
end

.subclassesObject



16
17
18
# File 'lib/usaidwat/command.rb', line 16

def subclasses
  @subclasses ||= []
end

Instance Method Details

#quit(message, code = :ok) ⇒ Object



31
32
33
34
35
# File 'lib/usaidwat/command.rb', line 31

def quit(message, code=:ok)
  stream = code == :ok ? $stdout : $stderr
  stream.puts message
  exit code
end