Sha256: fa00f429b364131e19b5ed46f3db1938ee2a7f5c9f74074bc83e3ed5d7b2a5d5

Contents?: true

Size: 625 Bytes

Versions: 6

Compression:

Stored size: 625 Bytes

Contents

require 'mida/datatype/generic'

module Mida
  module DataType

    # Boolean data type
    # Provides access to TrueClass/FalseClass methods
    class Boolean < Generic

      # Raises +ArgumentError+ if value not valid boolean
      def initialize(value)
        @parsedValue = case value.downcase
                       when 'true' then true
                       when 'false' then false
                       else raise ::ArgumentError, 'Invalid value'
                       end
      end

      def to_s
        @parsedValue.to_s.capitalize
      end

      def !@
        !@parsedValue
      end

    end

  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
mida-0.4.0 lib/mida/datatype/boolean.rb
mida-0.3.9 lib/mida/datatype/boolean.rb
mida-0.3.8 lib/mida/datatype/boolean.rb
mida-0.3.7 lib/mida/datatype/boolean.rb
mida-0.3.6 lib/mida/datatype/boolean.rb
mida-0.3.3 lib/mida/datatype/boolean.rb