Sha256: 212876d441208d504aa6b925f9b5c358ea1dfeeca9d0276c45b555ed17f33d51

Contents?: true

Size: 812 Bytes

Versions: 36

Compression:

Stored size: 812 Bytes

Contents

module Avo
  module Fields
    class DateField < TextField
      attr_reader :first_day_of_week
      attr_reader :picker_format
      attr_reader :format
      attr_reader :relative

      def initialize(id, **args, &block)
        super(id, **args, &block)

        @first_day_of_week = args[:first_day_of_week].present? ? args[:first_day_of_week].to_i : 0
        @picker_format = args[:picker_format].present? ? args[:picker_format] : "Y-m-d"
        @format = args[:format].present? ? args[:format] : :long
        @relative = args[:relative].present? ? args[:relative] : false
      end

      def formatted_value
        return if value.blank?

        if @format.is_a?(Symbol)
          value.to_formatted_s(@format)
        else
          value.strftime(@format)
        end
      end
    end
  end
end

Version data entries

36 entries across 36 versions & 1 rubygems

Version Path
avo-2.5.0 lib/avo/fields/date_field.rb
avo-2.4.1 lib/avo/fields/date_field.rb
avo-2.4.0 lib/avo/fields/date_field.rb
avo-2.3.1.pre.6 lib/avo/fields/date_field.rb
avo-2.3.1.pre.5 lib/avo/fields/date_field.rb
avo-2.3.1.pre.4 lib/avo/fields/date_field.rb
avo-2.3.1.pre.3 lib/avo/fields/date_field.rb
avo-2.3.1.pre.2 lib/avo/fields/date_field.rb
avo-2.3.1.pre.1 lib/avo/fields/date_field.rb
avo-2.3.0 lib/avo/fields/date_field.rb
avo-2.2.2 lib/avo/fields/date_field.rb
avo-2.2.1 lib/avo/fields/date_field.rb
avo-2.2.0 lib/avo/fields/date_field.rb
avo-2.1.2.pre2 lib/avo/fields/date_field.rb
avo-2.1.2.pre1 lib/avo/fields/date_field.rb
avo-1.25.1 lib/avo/fields/date_field.rb