refactor: reintroduce RangeList

This commit is contained in:
Glenn Y. Rolland 2023-07-12 11:37:12 +02:00
parent 878c2cb95c
commit 49b541b8d9
2 changed files with 7 additions and 4 deletions

View file

@ -4,11 +4,11 @@ require "./spec_helper"
require "../src/timecost/range_list"
describe TimeCost::RangeList do
list= TimeCost::RangeList.new
list = TimeCost::RangeList.new
describe ".new" do
it "can be created without arguments" do
assert_instance_of TimeCost::RangeList, list
list.should be_a(TimeCost::RangeList)
end
end

View file

@ -4,7 +4,10 @@ module TimeCost
@ranges = [] of Range
end
def add(range : Range)
def add(commit : Commit) : RangeList
end
def add(range : Range) : RangeList
merged = false
merged_range = nil
@ -34,7 +37,7 @@ module TimeCost
end
end
def sum
def sum : Float
result = 0
@ranges.each do |r|
result += r.diff