Sha256: c4430bfa370bb3bffa31721835d36587e8452eca8dd97420118ff06ee30fdd9a

Contents?: true

Size: 533 Bytes

Versions: 26

Compression:

Stored size: 533 Bytes

Contents

class ImageOptim
  # Denote ternary value (`true`/`false`/`nil`) for worker option
  class TrueFalseNil
    # Add handling of ternary value in OptionParser instance, maps `nil` and
    # `'nil'` to `nil`
    def self.add_to_option_parser(option_parser)
      completing = OptionParser.top.atype[TrueClass][0].merge('nil' => nil)
      option_parser.accept(self, completing){ |_arg, val| val }
    end

    # Convert everything truthy to `true`, leave `false` and `nil` as is
    def self.convert(v)
      v && true
    end
  end
end

Version data entries

26 entries across 26 versions & 3 rubygems

Version Path
image_optim-0.19.0 lib/image_optim/true_false_nil.rb
image_optim-0.18.0 lib/image_optim/true_false_nil.rb
image_optim-0.17.1 lib/image_optim/true_false_nil.rb
image_optim-0.17.0 lib/image_optim/true_false_nil.rb
image_optim-0.16.0 lib/image_optim/true_false_nil.rb
image_optim-0.15.0 lib/image_optim/true_false_nil.rb