Sha256: 41caced1fde7b84e0e94996943bfed467c5af18ed94a311bb5f249a93005d3c6

Contents?: true

Size: 802 Bytes

Versions: 103

Compression:

Stored size: 802 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_s(@format)
        else
          value.strftime(@format)
        end
      end
    end
  end
end

Version data entries

103 entries across 103 versions & 1 rubygems

Version Path
avo-1.7.2 lib/avo/fields/date_field.rb
avo-1.7.1 lib/avo/fields/date_field.rb
avo-1.7.0 lib/avo/fields/date_field.rb
avo-1.6.4.pre.1 lib/avo/fields/date_field.rb
avo-1.6.3.pre.3 lib/avo/fields/date_field.rb
avo-1.6.3.pre.2 lib/avo/fields/date_field.rb
avo-1.6.3.pre.1 lib/avo/fields/date_field.rb
avo-1.6.2.pre.1 lib/avo/fields/date_field.rb
avo-1.6.1 lib/avo/fields/date_field.rb
avo-1.6.0 lib/avo/fields/date_field.rb
avo-1.5.5 lib/avo/fields/date_field.rb
avo-1.5.4 lib/avo/fields/date_field.rb
avo-1.5.3 lib/avo/fields/date_field.rb
avo-1.5.2 lib/avo/fields/date_field.rb
avo-1.5.1 lib/avo/fields/date_field.rb
avo-1.5.0 lib/avo/fields/date_field.rb
avo-1.4.5.pre.1 lib/avo/fields/date_field.rb
avo-1.4.4.pre.1 lib/avo/fields/date_field.rb
avo-1.4.4 lib/avo/fields/date_field.rb
avo-1.4.3 lib/avo/fields/date_field.rb