Sha256: 1b2c30122e018d4aea36a1742a6aaa8834c80387673d6c21688452e1245b99ff

Contents?: true

Size: 744 Bytes

Versions: 2

Compression:

Stored size: 744 Bytes

Contents

module Lino
  module Switches
    def with_option(switch, value, separator: nil, quoting: nil)
      with(switches: add_option(switch, value, separator, quoting))
    end

    def with_repeated_option(switch, values, separator: nil, quoting: nil)
      values.each do |value|
        add_option(switch, value, separator, quoting)
      end
      with({})
    end

    def with_flag(flag)
      with(switches: @switches.add({ components: [flag] }))
    end

    private

    def add_option(switch, value, separator, quoting)
      return @switches if missing?(value)

      @switches = @switches.add(
        {
          components: [switch, value],
          separator: separator,
          quoting: quoting
        }
      )
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
lino-1.9.0 lib/lino/switches.rb
lino-1.8.0.pre.2 lib/lino/switches.rb