Class: USaidWat::Application::Info
- Defined in:
- lib/usaidwat/commands/info.rb
Instance Attribute Summary
Attributes inherited from Command
Instance Method Summary collapse
-
#initialize(prog) ⇒ Info
constructor
A new instance of Info.
- #process(options, args) ⇒ Object
Methods inherited from Command
Methods included from Pager
Constructor Details
#initialize(prog) ⇒ Info
Returns a new instance of Info.
7 8 9 10 11 12 13 14 |
# File 'lib/usaidwat/commands/info.rb', line 7 def initialize(prog) prog.command(:info) do |c| c.action do |args, | process(, args) end end super end |
Instance Method Details
#process(options, args) ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/usaidwat/commands/info.rb', line 16 def process(, args) raise ArgumentError.new('You must specify a username') if args.empty? username = args.shift redditor = client.new(username) created_at = redditor.created_at.strftime("%b %d, %Y %H:%M %p") puts "Created: #{created_at} (#{redditor.age})" printf "Link Karma: %d\n", redditor.link_karma printf "Comment Karma: %d\n", redditor.comment_karma rescue USaidWat::Client::NoSuchUserError quit "No such user: #{username}", :no_such_user end |