Sha256: ceadef2be418ebd673f2bd4da8e2c2ae14c2bc3a31a327173fe73fcbb307246e

Contents?: true

Size: 403 Bytes

Versions: 5

Compression:

Stored size: 403 Bytes

Contents

# frozen_string_literal: true

module XDG
  PAIR_DELIMITER = "="

  # A generic key-value pair (KVP).
  Pair = Struct.new :key, :value do
    def to_env = Hash[*values]

    def key? = key.to_s.size.positive?

    def value? = value.to_s.size.positive?

    def empty? = !(key? && value?)

    def inspect
      return "" unless key? || value?

      "#{key}#{PAIR_DELIMITER}#{value}"
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
xdg-5.3.0 lib/xdg/pair.rb
xdg-5.2.0 lib/xdg/pair.rb
xdg-5.1.3 lib/xdg/pair.rb
xdg-5.1.2 lib/xdg/pair.rb
xdg-5.1.1 lib/xdg/pair.rb