class BitGirder::Core::ObjectPath
Attributes
parent[R]
Public Class Methods
get_root( root_elt )
click to toggle source
Returns a path starting with the specified root element
# File lib/bitgirder/core.rb, line 1225 def self.get_root( root_elt ) not_nil( root_elt, :root_elt ) DictionaryPath.send( :new, nil, root_elt ) end
get_root_list()
click to toggle source
# File lib/bitgirder/core.rb, line 1231 def self.get_root_list ListPath.send( :new, nil, 0 ) end
new( parent )
click to toggle source
Not to be called by public methods; all paths should be derived from a parent path or initialized with get_root
or get_root_list
# File lib/bitgirder/core.rb, line 1212 def initialize( parent ) @parent = parent # parent nil ==> this is a root path end
Public Instance Methods
descend( elt )
click to toggle source
# File lib/bitgirder/core.rb, line 1216 def descend( elt ) DictionaryPath.send( :new, self, not_nil( elt, "elt" ) ) end
format( formatter = DefaultObjectPathFormatter.new )
click to toggle source
# File lib/bitgirder/core.rb, line 1250 def format( formatter = DefaultObjectPathFormatter.new ) not_nil( formatter, "formatter" ) formatter.format_path_start( str = "" ) collect_path.each_with_index do |elt, idx| case elt when DictionaryPath formatter.format_separator( str ) unless idx == 0 formatter.format_key( str, elt.key ) when ListPath then formatter.format_list_index( str, elt.index ) else raise "Unexpected path type: #{elt.class}" end end str end
start_list()
click to toggle source
# File lib/bitgirder/core.rb, line 1220 def start_list ListPath.send( :new, self, 0 ) end
Private Instance Methods
collect_path()
click to toggle source
# File lib/bitgirder/core.rb, line 1236 def collect_path res = [ node = self ] # This loop is correct on the assumption that the caller obtained this # instance by the accepted means while node = node.parent res.unshift( node ) end res end