diff options
author | Saku Ytti <saku@ytti.fi> | 2013-04-17 17:48:50 +0300 |
---|---|---|
committer | Saku Ytti <saku@ytti.fi> | 2013-04-17 17:48:50 +0300 |
commit | 9d217025fac3e335c308f02e7377e14ccfdc0e66 (patch) | |
tree | b90d4d04947fe26a9e592e12d8c4352142380c03 /lib/oxidized/nodes.rb |
Initial commit
Silly for shit-and-giggles attempt at rancid
Diffstat (limited to 'lib/oxidized/nodes.rb')
-rw-r--r-- | lib/oxidized/nodes.rb | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/lib/oxidized/nodes.rb b/lib/oxidized/nodes.rb new file mode 100644 index 0000000..467d3a0 --- /dev/null +++ b/lib/oxidized/nodes.rb @@ -0,0 +1,36 @@ +module Oxidized + require 'oxidized/node' + class Nodes < Array + attr_accessor :source + alias :del :delete + def initialize *args + super + load if args.empty? + end + def load + new = [] + @source = CFG.source[:default] + Oxidized.mgr.source = @source + Oxidized.mgr.source[@source].new.load.each do |node| + new.push Node.new node + end + replace new + end + def list + self + end + # @param node [String] name of the node inserted into nodes array + def put node + unshift node + end + # @param node [String] name of the node moved into the head of array + def top node + n = del node + put n if n + end + # @return [String] node from the head of the array + def get + (self << shift).last + end + end +end |