Module: CopyrightYears
- Defined in:
- lib/copyright.rb
Overview
Adds a method for copyright period
Instance Method Summary
- - (Object) copyright_years(since) Returns copyright period in years.
Instance Method Details
- (Object) copyright_years(since)
Returns copyright period in years
12 13 14 15 16 17 18 19 20 |
# File 'lib/copyright.rb', line 12 def copyright_years(since) raise ArgumentError, "Argument should be a number" unless since.is_a?(Integer) raise ArgumentError, "since should not be a future" if Date.civil(since).year > Date.today.year if Date.civil(since).year == Date.today.year since.to_s else "#{since} - #{Date.today.year}" end end |