Module: Hab::Formatter::ClassMethods

Included in:
Hab::Formatter
Defined in:
lib/hab/formatter.rb

Instance Method Summary collapse

Instance Method Details

#stats(stats) ⇒ Object



28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'lib/hab/formatter.rb', line 28

def stats(stats)
  "HP \#{stats.hp}\nMAX_HP \#{stats.max_health}\nMP \#{stats.mp}\nMAX_MP \#{stats.max_mp}\nEXP \#{stats.exp}\nTO_NEXT_LEVEL \#{stats.to_next_level}\nPER \#{stats.per}\nINT \#{stats.int}\nCON \#{stats.con}\nSTR \#{stats.str}\nLVL \#{stats.lvl}\nGP \#{stats.gp}\n"
end

#status(client) ⇒ Object



13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/hab/formatter.rb', line 13

def status(client)
  stats = client.user.stats
  dailies = client.tasks.dailies
  todos = client.tasks.todos
  dailies_complete_count = dailies.count(&:completed?)
  todos_complete_count = todos.count(&:completed?)
  "\#{statbar(:HP, stats.hp, stats.max_health)}\n\#{statbar(:EXP, stats.exp, stats.to_next_level)}\n\#{statbar(:MP, stats.mp, stats.max_mp)}\n\#{statbar(:DAILIES, dailies_complete_count, dailies.count)}\n\#{statbar(:TODOS, todos_complete_count, todos.count)}\n"
end

#task(task, options = {}) ⇒ Object



49
50
51
52
53
54
55
56
57
58
59
60
61
# File 'lib/hab/formatter.rb', line 49

def task(task, options = {})
  if options[:emoji] == true
    Rumoji
      .decode(task.text)
      .colorize(value_color(task.value))
  else
    Rumoji
      .erase(task.text)
      .gsub(/\ \ /, ' ')
      .strip
      .colorize(value_color(task.value))
  end
end

#tasks(tasks, options = {}) ⇒ Object



45
46
47
# File 'lib/hab/formatter.rb', line 45

def tasks(tasks, options = {})
  tasks.map { |task| task(task, options) }.join("\n")
end