module Psychgus::Ext::NodeExt
Extensions to Psych::Nodes::Node.
@author Jonathan Bradley Whited @since 1.0.0
Public Instance Methods
node_of?(*names)
click to toggle source
Check if this Node is of a certain type (Alias, Mapping, Scalar, Sequence, etc.).
New versions of Psych have alias?(), mapping?(), etc., so this is for old versions.
This is equivalent to the following (with less typing):
node.is_a?(Psych::Nodes::Alias) node.is_a?(Psych::Nodes::Mapping) node.is_a?(Psych::Nodes::Scalar) node.is_a?(Psych::Nodes::Sequence)
@example
node.node_of?(:alias) node.node_of?(:mapping) node.node_of?(:scalar) node.node_of?(:sequence) node.node_of?(:alias,:mapping,:scalar,:sequence) # OR node.node_of?(:doc,:map,:seq) # OR
@param names [Symbol,String] the type(s) to check using OR
@return [true,false] true if this Node is one of the names
type, else false
@see Psychgus.node_class
# File lib/psychgus/ext/node_ext.rb, line 46 def node_of?(*names) names.each do |name| return true if is_a?(Psychgus.node_class(name)) end return false end