-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: Split Numeric core extensions out.
These are not used directly by Time::Iterator, but are for convenience. They may be removed later.
- Loading branch information
Showing
4 changed files
with
21 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
# Inject 3.quarters | ||
class Numeric | ||
def quarter | ||
(3 * self).months | ||
end | ||
alias quarters quarter | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
RSpec.describe Numeric do | ||
let(:time) { Time.now } | ||
|
||
describe '#quarter(s)' do | ||
[:quarter, :quarters].each do |method| | ||
it 'adds 3 months per quarter' do | ||
expect( time + 1.send(method) ).to eq time + 3.months | ||
expect( time + 3.send(method) ).to eq time + 9.months | ||
expect( time + 4.send(method) ).to eq time + 1.year | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters