Sha256: 1ea4043a3ebab588cf3a64a9da8f2a3e45dd82ecf5d64ff6013c959ec2436120

Contents?: true

Size: 1.28 KB

Versions: 6

Compression:

Stored size: 1.28 KB

Contents

# -*- ruby -*-
#encoding: utf-8

require 'arborist/node' unless defined?( Arborist::Node )
require 'arborist/mixins'


# The class of the root node of an Arborist tree. This class is a Singleton.
class Arborist::Node::Root < Arborist::Node
	extend Arborist::MethodUtilities


	# The instance of the Root node.
	@instance = nil

	### Create the instance of the Root node (if necessary) and return it.
	def self::new( * )
		@instance ||= super
		return @instance
	end


	### Override the default constructor to use the singleton ::instance instead.
	def self::instance( * )
		@instance ||= new
		return @instance
	end


	### Reset the singleton instance; mainly used for testing.
	def self::reset
		@instance = nil
	end


	### Set up the root node.
	def initialize( * )
		super( '_' ) do
			description "The root node."
			source = URI( __FILE__ )
		end

		@status = 'up'
		@status.freeze
	end


	### Ignore restores of serialized root nodes.
	def restore( other_node )
		self.log.info "Ignoring restored root node."
	end


	### Ignore updates to the root node.
	def update( properties )
		self.log.warn "Update to the root node ignored."
	end


	### Override the reader mode of Node#parent for the root node, which never has
	### a parent.
	def parent( * )
		return nil
	end

end # class Arborist::Node::Root

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
arborist-0.2.0.pre20170519125456 lib/arborist/node/root.rb
arborist-0.1.0 lib/arborist/node/root.rb
arborist-0.0.1.pre20161005182540 lib/arborist/node/root.rb
arborist-0.0.1.pre20161005112841 lib/arborist/node/root.rb
arborist-0.0.1.pre20160829140603 lib/arborist/node/root.rb
arborist-0.0.1.pre20160606141735 lib/arborist/node/root.rb