Sha256: f8b1810e6883f6f75c9da1b981efce0cf68f8618fda70b92e0a2294c84b09d48

Contents?: true

Size: 712 Bytes

Versions: 25

Compression:

Stored size: 712 Bytes

Contents

module Sprout

  module Executable

    # Concrete param object for :boolean values
    class Boolean < Param
      attr_accessor :show_on_false

      def initialize
        super
        @delimiter               = ' '
        @option_parser_type_name = 'BOOL'
        @show_on_false           = false
        @value                   = false
        @hidden_value            = true
      end

      def value=(value)
        value = (value == "true" || value === true) ? true : false 
        super value
      end
      
      def visible?
        @visible ||= value
        if(show_on_false)
          return true unless value
        else
          return @visible
        end
      end

    end
  end
end

Version data entries

25 entries across 25 versions & 1 rubygems

Version Path
sprout-1.0.4.pre lib/sprout/executable/boolean.rb
sprout-1.0.3.pre lib/sprout/executable/boolean.rb
sprout-1.0.2.pre lib/sprout/executable/boolean.rb
sprout-1.0.1.pre lib/sprout/executable/boolean.rb
sprout-1.0.0.pre lib/sprout/executable/boolean.rb