Sha256: 5e7f349dd2c94308224b162c1e156e66ab65e6c4cc03b8f5bdf17804db7f72c1

Contents?: true

Size: 747 Bytes

Versions: 1

Compression:

Stored size: 747 Bytes

Contents

module CopyrightPresenter

  class Copyright

    attr_reader :company, :start_year

    def initialize( company, start_year=Time.now.strftime( '%Y' ) )
      @company    = company
      @start_year = start_year
    end

    def long( options={:single_year => false} )
      "#{short( options )} All Rights Reserved."
    end

    def short( options={:single_year => false} )
      "Copyright #{symbol} #{years( options )} #{company}."
    end

    def symbol
      "©"
    end

  protected

    def current_year
      Time.now.strftime( '%Y' )
    end

    def years( options )
      if options[:single_year] || start_year == current_year
        return current_year
      end

      return "#{start_year} - #{current_year}"
    end

  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
copyright_presenter-1.0.0 lib/copyright_presenter/copyright.rb