class Etcd::Node

This class represents an etcd node

Attributes

createdIndex[R]
created_index[R]
dir[R]
expiration[R]
key[R]
modifiedIndex[R]
modified_index[R]
ttl[R]
value[R]

Public Class Methods

new(opts = {}) click to toggle source

rubocop:disable MethodLength

# File lib/etcd/node.rb, line 12
def initialize(opts = {})
  @created_index = opts['createdIndex']
  @modified_index = opts['modifiedIndex']
  @ttl = opts['ttl']
  @key = opts['key']
  @value = opts['value']
  @expiration = opts['expiration']
  @dir = opts['dir']

  if opts['dir'] && opts['nodes']
    opts['nodes'].each do |data|
      children << Node.new(data)
    end
  end
end

Public Instance Methods

<=>(other) click to toggle source
# File lib/etcd/node.rb, line 28
def <=>(other)
  key <=> other.key
end
children() click to toggle source
# File lib/etcd/node.rb, line 32
def children
  if directory?
    @children ||= []
  else
    fail 'This is not a directory, cant have children'
  end
end
directory?() click to toggle source
# File lib/etcd/node.rb, line 40
def directory?
  ! @dir.nil?
end