Sha256: e59347f641597ecff184466d29f7031932ebf3eecc4063353fc80cc4e2bec9da

Contents?: true

Size: 377 Bytes

Versions: 3

Compression:

Stored size: 377 Bytes

Contents

module NsOptions
  class Boolean

    attr_accessor :actual

    def initialize(value)
      self.actual = value
    end

    def actual=(new_value)
      @actual = self.convert(new_value)
    end

    protected

    def convert(value)
      if [ nil, 0, '0', false, 'false', 'f', 'F' ].include?(value)
        false
      elsif value
        true
      end
    end

  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
ns-options-0.3.1 lib/ns-options/boolean.rb
ns-options-0.3.0 lib/ns-options/boolean.rb
ns-options-0.2.0 lib/ns-options/boolean.rb