Sha256: cf1c1a27fca47ac64d1de5d72f5b2eac9aa413414ce09d507eefd7292699bf5a

Contents?: true

Size: 839 Bytes

Versions: 5

Compression:

Stored size: 839 Bytes

Contents

module ReportCat
  module Core
    class Param

      attr_reader :name, :type, :value, :options

      def initialize( attributes = {} )
        @name = attributes[ :name ]
        @type = attributes[ :type ]
        @value = attributes[ :value ]
        @options = attributes[ :options ] || {}
      end

      def value=( value )
        @value = case @type
          when :check_box then ( value == '1' || value == true || value == 'true' )
          when :date
            if value.kind_of?( Hash )
              Date.new( value[:year].to_i, value[:month].to_i, value[:day].to_i )
            elsif value.kind_of?( String )
              Date.parse( value )
            else
              value
            end
          else value
        end
      end

      def hide
        @options[ :hidden ] = true
      end

    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
report_cat-5.0.3 lib/report_cat/core/param.rb
report_cat-5.0.2 lib/report_cat/core/param.rb
report_cat-5.0.1 lib/report_cat/core/param.rb
report_cat-5.0.0 lib/report_cat/core/param.rb
report_cat-0.2.0 lib/report_cat/core/param.rb