Class: LogworkManager::Insert

Inherits:
Command
  • Object
show all
Defined in:
lib/logwork_manager/command.rb

Overview

Command for insert action

Instance Method Summary collapse

Constructor Details

#initialize(arguments, workday_hours) ⇒ Insert

Returns a new instance of Insert.



68
69
70
71
# File 'lib/logwork_manager/command.rb', line 68

def initialize(arguments, workday_hours)
  super
  @position_to_insert = @args.empty? ? 0 : Integer(@args[0])
end

Instance Method Details

#update_issues(issues, issue_to_add) ⇒ Object



73
74
75
76
77
78
79
80
# File 'lib/logwork_manager/command.rb', line 73

def update_issues(issues, issue_to_add)
  raise LogworkException::ArgumentError, "Missing issue param" if issue_to_add.nil?

  issues = [] if issues.nil?

  @position_to_insert = issues.size if @position_to_insert > issues.size
  issues.insert(@position_to_insert, issue_to_add)
end