Sha256: 38d43f5ccd8eaa508264e7b50da0460e5a3ca643be17d8c185e9535ff0d5ab65

Contents?: true

Size: 1.07 KB

Versions: 4

Compression:

Stored size: 1.07 KB

Contents

module Rbnotes::Commands
  ##
  # Shows statistics.

  class Statistics < Command

    def description             # :nodoc:
      "Show statistics values"
    end

    def execute(args, conf)
      report = :total
      while args.size > 0
        arg = args.shift
        case arg
        when "-y", "--yearly"
          report = :yearly
          break
        when "-m", "--monthly"
          report = :monthly
          break
        else
          args.unshift(arg)
          raise ArgumentError, "invalid option or argument: %s" % args.join(" ")
        end
      end

      stats = Rbnotes::Statistics.new(conf)
      case report
      when :yearly
        stats.yearly_report
      when :monthly
        stats.monthly_report
      else
        stats.total_report
      end
    end

    def help
      puts <<HELP
usage:
    #{Rbnotes::NAME} statistics ([-y|--yearly]|[-m|--monthly])

option:
    -y, --yearly  : print yearly report
    -m, --monthly : print monthly report

Show statistics.

In the version #{Rbnotes::VERSION}, only number of notes is supported.
HELP
    end

  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
rbnotes-0.4.14 lib/rbnotes/commands/statistics.rb
rbnotes-0.4.13 lib/rbnotes/commands/statistics.rb
rbnotes-0.4.12 lib/rbnotes/commands/statistics.rb
rbnotes-0.4.11 lib/rbnotes/commands/statistics.rb