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.



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

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

Instance Attribute Details

#issueObject

Focusing on the current issue



47
48
49
# File 'lib/wlog/ui/issue_ui.rb', line 47

def issue
  @issue
end

Instance Method Details

#runObject

Start up the interface



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

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

    case cmd
    when /^new/     then new_entry
    when /^show/    then show_entries
    when /^desc/    then describe_issue
    when /^delete/  then delete_entry
    when /^search/  then search_term
    when /^concat/  then concat_description
    when /^replace/ then replace_pattern
    when /^search/  then search_term
    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
    else puts "Type 'help' for help"
    end
  end
end