Class: Overtime::OutOfHoursQuery

Inherits:
Object
  • Object
show all
Defined in:
lib/overtime/out_of_hours_query.rb

Instance Method Summary collapse

Constructor Details

#initialize(repo, options = {}) ⇒ OutOfHoursQuery

Returns a new instance of OutOfHoursQuery.



6
7
8
9
10
11
12
# File 'lib/overtime/out_of_hours_query.rb', line 6

def initialize(repo, options = {})
  @repo = repo
  @branch = options.fetch(:branch, 'master')
  @count = options.fetch(:count, @repo.commit_count)
  @start = options.fetch(:start, 9)
  @end = options.fetch(:end, 18)
end

Instance Method Details

#presentObject



20
21
22
# File 'lib/overtime/out_of_hours_query.rb', line 20

def present
  run.map { |commit| OutOfHoursPresenter.new(commit, @start, @end) }
end

#runObject



14
15
16
17
18
# File 'lib/overtime/out_of_hours_query.rb', line 14

def run
  @repo.commits(@branch, @count).select do |commit|
    out_of_hours?(commit)
  end
end