Sha256: 6b62a077d1f6162f922d206b265cba17cc2ace4dd9da93c667f07a5b949b648e

Contents?: true

Size: 878 Bytes

Versions: 1

Compression:

Stored size: 878 Bytes

Contents

require 'usaidwat/client'
require 'usaidwat/command'

module USaidWat
  module Application
    class Info < Command
      def initialize(prog)
        prog.command(:info) do |c|
          c.action do |args, options|
            dispatch_process(:process, options, args)
          end
        end
        super
      end

      def process(options, 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
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
usaidwat-1.6.1 lib/usaidwat/commands/info.rb