module Eco::Data::Locations module NodeBase require_relative 'node_base/tag_validations' include Eco::Data::Locations::NodeBase::TagValidations require_relative 'node_base/treeify' require_relative 'node_base/parsing' require_relative 'node_base/serial' require_relative 'node_base/csv_convert' require_relative 'node_base/builder' extend Eco::Data::Locations::NodeBase::Builder ALL_ATTRS = [] attr_accessor :tracked_level, :parent def copy self.class.new.set_attrs(**self.to_h) end def attr(sym) self.send(sym.to_sym) end def attr?(sym) !attr(sym).to_s.strip.empty? end def set_attrs(**kargs) kargs.each {|attr, value| set_attr(attr, value)} self end def set_attr(attr, value) self.send("#{attr}=", value) end def values_at(*attrs) attrs.map {|a| attr(a)} end def to_h(*attrs) attrs = self.class::ALL_ATTRS if attrs.empty? attrs.zip(values_at(*attrs)).to_h end def slice(*attrs) return {} if attrs.empty? to_h(*attrs) end end end