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`



8
9
10
11
# 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) ⇒ Object

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



14
15
16
# File 'lib/image_optim/true_false_nil.rb', line 14

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