Sha256: ca6e89430c14fa38ced5c4bde1d8f74324575aee7423d876c4767b152a0aaf68

Contents?: true

Size: 577 Bytes

Versions: 1

Compression:

Stored size: 577 Bytes

Contents

# frozen_string_literal: true

module Lutaml
  module Path
    class ElementPath
      attr_reader :segments, :absolute

      def initialize(segments, absolute: false)
        @segments = Array(segments)
        @absolute = absolute
      end

      def absolute?
        @absolute
      end

      def match?(path_segments)
        return false if absolute? && path_segments.length != segments.length
        return false if path_segments.length < segments.length

        segments.zip(path_segments).all? { |seg, path_seg| seg.match?(path_seg) }
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
lutaml-path-0.1.0 lib/lutaml/path/element_path.rb