Class: ImageOptim::TrueFalseNil

Inherits:
Object
  • Object
show all
Defined in:
lib/image_optim/true_false_nil.rb

Overview

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

Class Method Summary collapse

Class Method Details

.add_to_option_parser(option_parser) ⇒ Object

Add handling of ternary value in OptionParser instance, maps nil and ‘’nil’‘ to nil



6
7
8
9
# File 'lib/image_optim/true_false_nil.rb', line 6

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(v) ⇒ Object

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



12
13
14
# File 'lib/image_optim/true_false_nil.rb', line 12

def self.convert(v)
  v && true
end