Sha256: 6a3a2c410f256e2ad060156a99d420510a6d30a92e5748dfdf287adff8de6645

Contents?: true

Size: 688 Bytes

Versions: 1

Compression:

Stored size: 688 Bytes

Contents

# -*- coding: utf-8 -*-

# Adds a method for copyright period
# @author Takaaki Kato <takaaki.kato@gmail.com>
module CopyrightHelper
  # Returns copyright period in years
  # @example When the argument is the year of now
  #   copyright_years(2009) #=> "2009"
  # @example When the argument if before of this year
  #   copyright_years(1997) #=> "1997-2009"
  # @param [#is_a?(Integer)]
  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 since > Time.new.year
    if since == Time.new.year
      "#{since}"
    else
      "#{since}-#{Time.new.year}"
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
copyright-0.1.5 lib/copyright_helper.rb