Sha256: de26646515c0792e9e588e62e511c08dfbed6f8e1cbbaa13188b6eb86e79bba0

Contents?: true

Size: 465 Bytes

Versions: 7

Compression:

Stored size: 465 Bytes

Contents

require 'date'
module PR
  module Fields
    class DateField
      Format = '%d/%m/%Y'

      def initialize value = '', options = {}
        @value, @options = value, options
      end
      attr_reader :options

      def raw
        @value
      end

      def populate date
        @value = date.strftime Format
      end

      def convert
        Date.strptime(@value,Format)
      rescue ArgumentError
        raise InvalidValue
      end

    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
pr-1.0.0 lib/pr/fields/date_field.rb
pr-0.0.7 lib/pr/fields/date_field.rb
pr-0.0.6 lib/pr/fields/date_field.rb
pr-0.0.5 lib/pr/fields/date_field.rb
pr-0.0.4 lib/pr/fields/date_field.rb
pr-0.0.3 lib/pr/fields/date_field.rb
pr-0.0.2 lib/pr/fields/date_field.rb