Class: Wlog::IssueUi

Inherits:
Object
  • Object
show all
Defined in:
lib/wlog/ui/issue_ui.rb

Overview

Author:

  • Simon

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(db, issue) ⇒ IssueUi

Returns a new instance of IssueUi.



16
17
18
19
20
# File 'lib/wlog/ui/issue_ui.rb', line 16

def initialize(db, issue)
  @issue = issue
  @db = db
  @strmaker = SysConfig.string_decorator
end

Instance Attribute Details

#issueObject

Focusing on the current issue



49
50
51
# File 'lib/wlog/ui/issue_ui.rb', line 49

def issue
  @issue
end

Instance Method Details

#runObject

Start up the interface



23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
# File 'lib/wlog/ui/issue_ui.rb', line 23

def run
  cmd = "default"
  until cmd == "end" do
    cmd = Readline.readline("[issue ##{@issue.id}] ") || ""
    cmd.chomp!

    case cmd
    when /^new/       then new_entry
    when /^(ls|show)/ then show_entries
    when /^desc/      then describe_issue
    when /^delete/    then delete_entry
    when /^edit/      then edit_what(cmd.split.drop 1)
    when /^concat/    then concat_description
    when /^replace/   then replace_pattern
    when /^search/    then search_term(cmd.split.drop 1)
    when /^lt/        then time(cmd.split.drop 1) # lt for log time
    when /^forget/    then cmd = "end"
    when /^finish/    then finish.nil? ? nil : cmd = "end"
    when /^help/      then print_help
    when /^end/       then next
    else puts "Type 'help' for help"
    end
  end
end