From 5d7a3ca82907258561a0cf8c23f9b4d8a1fff13d Mon Sep 17 00:00:00 2001 From: Jeffrey Phillips Freeman <the@jeffreyfreeman.me> Date: Thu, 17 Aug 2023 17:23:37 -0400 Subject: [PATCH] Added empty? to paths --- lib/apex/frame/immutable_path.rb | 5 +++++ lib/apex/frame/path.rb | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/lib/apex/frame/immutable_path.rb b/lib/apex/frame/immutable_path.rb index bfd90c3..b04cf39 100644 --- a/lib/apex/frame/immutable_path.rb +++ b/lib/apex/frame/immutable_path.rb @@ -68,6 +68,11 @@ module Apex return @path_array.length end + public + def empty? + return @path_array.empty? + end + public def eql?(other) raise ArgumentError.new("The argument must be of type Path (or a child class).") if not other.kind_of? Path diff --git a/lib/apex/frame/path.rb b/lib/apex/frame/path.rb index 0bbdfe3..75af1dc 100644 --- a/lib/apex/frame/path.rb +++ b/lib/apex/frame/path.rb @@ -3,6 +3,6 @@ module Apex module Path include Abstractify::Abstract - abstract :each, :[], :length, :eql?, :==, :to_s, :to_string_array, :to_array + abstract :each, :[], :length, :eql?, :==, :to_s, :to_string_array, :to_array, :empty? end end -- GitLab