Sha256: 0c6e6169fb5bc873f9e0762522dfaad62b690e70f597c5ecae717efb3c17fa27

Contents?: true

Size: 636 Bytes

Versions: 6

Compression:

Stored size: 636 Bytes

Contents

require 'mida_vocabulary/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_vocabulary-0.2.2 lib/mida_vocabulary/datatype/boolean.rb
mida_vocabulary-0.2 lib/mida_vocabulary/datatype/boolean.rb
mida_vocabulary-0.1.3 lib/mida_vocabulary/datatype/boolean.rb
mida_vocabulary-0.1.2 lib/mida_vocabulary/datatype/boolean.rb
mida_vocabulary-0.1.1 lib/mida_vocabulary/datatype/boolean.rb
mida_vocabulary-0.1 lib/mida_vocabulary/datatype/boolean.rb