Class: TempestTime::Commands::Track

Inherits:
TempestTime::Command show all
Defined in:
lib/tempest_time/commands/track.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from TempestTime::Command

#command, #current_user, #date_prompt, #execute, #find_user, #pastel, #prompt, #spinner, #table, #week_prompt, #with_spinner, #with_success_fail_spinner

Methods included from Helpers::GitHelper

#automatic_issue

Methods included from Helpers::FormattingHelper

#braced, #with_percent_sign

Methods included from Helpers::TimeHelper

#beginning_of_week, #dates_in_range, #end_of_week, #formatted_date, #formatted_date_range, #formatted_time, #formatted_time_for_input, #formatted_time_long, #future_dates, #parsed_time, #past_dates, #past_week_selections, #week_beginnings, #week_dates

Constructor Details

#initialize(time, issues, options) ⇒ Track

Returns a new instance of Track.



12
13
14
15
16
17
18
# File 'lib/tempest_time/commands/track.rb', line 12

def initialize(time, issues, options)
  @options = options
  @issues = issues.any? ? issues.map(&:upcase) : [automatic_issue]
  @time = parsed_time(time) / @issues.count
  @dates = options[:date] ? [Date.parse(options[:date])] : nil
  @user = current_user
end

Instance Attribute Details

#issuesObject (readonly)

Returns the value of attribute issues.



10
11
12
# File 'lib/tempest_time/commands/track.rb', line 10

def issues
  @issues
end

#optionsObject (readonly)

Returns the value of attribute options.



10
11
12
# File 'lib/tempest_time/commands/track.rb', line 10

def options
  @options
end

#timeObject (readonly)

Returns the value of attribute time.



10
11
12
# File 'lib/tempest_time/commands/track.rb', line 10

def time
  @time
end

#userObject (readonly)

Returns the value of attribute user.



10
11
12
# File 'lib/tempest_time/commands/track.rb', line 10

def user
  @user
end

Instance Method Details

#execute!Object



20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/tempest_time/commands/track.rb', line 20

def execute!
  dates

  unless options[:autoconfirm]
    confirm_prompt
  end
  dates.each do |date|
    issues.each do |issue|
      track_time(time, options.merge({ issue: issue, date: date, user: user }))
    end
  end
end