Class: Helm::Commands::Create

Inherits:
Command
  • Object
show all
Defined in:
lib/helm/commands/create.rb

Instance Attribute Summary

Attributes inherited from Command

#session

Instance Method Summary collapse

Methods inherited from Command

#cache, #format, #initialize, #parameters

Constructor Details

This class inherits a constructor from Helm::Commands::Command

Instance Method Details

#runObject



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/helm/commands/create.rb', line 16

def run
  ticket = nil

  while line = $stdin.gets
    line.strip!

    if line.empty?
      save(ticket)
      ticket = nil
      next
    end

    if ticket.nil?
      ticket = session.new_ticket
      ticket.title = line
    else
      unless line.empty?
        ticket.body << line
        ticket.body << "\n"
      end
    end
  end

  save(ticket)
end