lib/sycamore/path.rb in sycamore-0.3.0 vs lib/sycamore/path.rb in sycamore-0.3.1
- old
+ new
@@ -1,5 +1,7 @@
+require 'forwardable'
+
module Sycamore
##
# A compact, immutable representation of Tree paths, i.e. node sequences.
#
@@ -19,10 +21,11 @@
# pure Array-based implementation (where tree nodes are duplicated), esp. in
# the most common use case of property-value structures.
#
class Path
include Enumerable
+ extend Forwardable
attr_reader :node, :parent
########################################################################
# @group Construction
@@ -72,9 +75,11 @@
end
########################################################################
# @group Elements
########################################################################
+
+ def_delegators :to_a, :[], :fetch
##
# Returns a new path based on this path, but with the given nodes extended.
#
# @param nodes [nodes] an arbitrary number of nodes