Sha256: 59f0111c025306ec32702c54cca037056e813599d632597dc8b71cf9b39b4526

Contents?: true

Size: 532 Bytes

Versions: 1

Compression:

Stored size: 532 Bytes

Contents

module PR
  module Fields
    class BooleanField
      TrueValues  = [1,"1","true",true]
      FalseValues = [0,"0","false",false, ""]

      def initialize value = nil
        @value = value
      end

      def populate value
        @value = value
      end

      def raw
        convert
      end

      def convert
        if TrueValues.include? @value
          return true
        elsif FalseValues.include? @value
          return false
        else
          @value ? true : false
        end
      end

    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
pr-0.0.1 lib/pr/fields/boolean_field.rb