Sha256: ee1c41f72051bc901d3f9d99443e0aac55e61d67dbb5225343f05b8df1820f91
Contents?: true
Size: 1.42 KB
Versions: 1
Compression:
Stored size: 1.42 KB
Contents
require 'exa/version' require 'exa/tree_node' require 'exa/visitor' module Exa class Process def initialize(title) @title = title end def register Process.table += [ self ] end def unregister Process.table -= [ self ] end def run! register perform! unregister end def self.table @table ||= [] end end class Copier < Process def initialize(source, target) @source = source @target = target super("copy #{source} -> #{target}") end def perform! @target.update @source.value end end class Deleter < Process def initialize(target) @target = target super("delete #{target}") end def perform! @target.parent.remove_child(child_name: @target.name) end end class << self def remember(path, value) p [ :remember, path: path, value: value ] recall(path).update(value) end alias :[]= :remember def recall(path) p [ :recall, path: path ] visitor.seek(path) end alias :[] :recall def expand(path) visitor.query(path) end alias :call :expand def clean_slate! @root = TreeNode.new(name: '', value: '(root)') # @visitor = Visitor.new(@root) end private def visitor Visitor.new(root) end def root @root ||= TreeNode.new(name: '', value: '(system root)') end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
exa-0.1.0 | lib/exa.rb |