Sha256: 4c6373e1ee52d037bee39d0464b86b8343d4b127431002836913e5be27a2bb70

Contents?: true

Size: 451 Bytes

Versions: 11

Compression:

Stored size: 451 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]
    end

    def key?
      key.to_s.size.positive?
    end

    def value?
      value.to_s.size.positive?
    end

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

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

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

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
xdg-5.1.0 lib/xdg/pair.rb
xdg-5.0.0 lib/xdg/pair.rb
xdg-4.5.0 lib/xdg/pair.rb
xdg-4.4.0 lib/xdg/pair.rb
xdg-4.3.0 lib/xdg/pair.rb
xdg-4.2.0 lib/xdg/pair.rb
xdg-4.1.0 lib/xdg/pair.rb
xdg-4.0.1 lib/xdg/pair.rb
xdg-4.0.0 lib/xdg/pair.rb
xdg-3.1.1 lib/xdg/pair.rb
xdg-3.1.0 lib/xdg/pair.rb