Sha256: f3ddd5c1a4c529ad1eadf3b81997b47b4b503d36d9525483c3ac963602aeb45e

Contents?: true

Size: 745 Bytes

Versions: 5

Compression:

Stored size: 745 Bytes

Contents

module HabiticaCli
  # Responsible for displaying a "dashboard" of stats
  # and tasks for a user as well as caching them
  module Commands
    def self.status(env)
      get_user_tasks(env)
      get_user_info(env)
    end

    def self.status_display(data)
      stats = data['stats']
      puts [
        "Gold: #{stats['gp'].round}",
        "Health: #{stats['hp'].round}/#{stats['maxHealth']}"
      ].join(' | ')
    end

    private_class_method

    def self.get_user_info(env)
      user_response = env.api.get('user')
      status_display(user_response.body['data'])
    end

    def self.get_user_tasks(env)
      task_response = env.api.get('tasks/user', type: 'dailys')
      display(env, task_response.body, nil)
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
habitica_cli-1.0.2 lib/habitica_cli/commands/status.rb
habitica_cli-1.0.1 lib/habitica_cli/commands/status.rb
habitica_cli-1.0.0 lib/habitica_cli/commands/status.rb
habitica_cli-0.1.1 lib/habitica_cli/commands/status.rb
habitica_cli-0.1.0 lib/habitica_cli/commands/status.rb