Module: Psychgus::Ext::NodeExt
- Defined in:
- lib/psychgus/ext/node_ext.rb
Overview
Extensions to Psych::Nodes::Node.
Instance Method Summary collapse
-
#node_of?(*names) ⇒ true, false
Check if this Node is of a certain type (Alias, Mapping, Scalar, Sequence, etc.).
Instance Method Details
#node_of?(*names) ⇒ true, false
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)
42 43 44 45 46 47 48 |
# File 'lib/psychgus/ext/node_ext.rb', line 42 def node_of?(*names) names.each do |name| return true if is_a?(Psychgus.node_class(name)) end return false end |