class ImageOptim::TrueFalseNil

Denote ternary value (`true`/`false`/`nil`) for worker option

Public Class Methods

add_to_option_parser(option_parser) click to toggle source

Add handling of ternary value in OptionParser instance, maps `nil` and `'nil'` to `nil`

# File lib/image_optim/true_false_nil.rb, line 8
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(value) click to toggle source

Convert everything truthy to `true`, leave `false` and `nil` as is

# File lib/image_optim/true_false_nil.rb, line 14
def self.convert(value)
  value && true
end