class CC::Yaml::Nodes::Sequence
Attributes
__getobj__[R]
children[R]
Public Class Methods
[](node_type)
click to toggle source
# File lib/cc/yaml/nodes/sequence.rb, line 7 def self.[](node_type) node_type = Scalar[node_type] unless node_type.is_a? Node Class.new(self) { type(node_type) } end
type(identifier = nil)
click to toggle source
# File lib/cc/yaml/nodes/sequence.rb, line 12 def self.type(identifier = nil) @type = Nodes[identifier] if identifier @type ||= superclass.respond_to?(:type) ? superclass.type : nil end
Public Instance Methods
==(other)
click to toggle source
# File lib/cc/yaml/nodes/sequence.rb, line 59 def ==(other) other = other.children if other.is_a? Sequence if other.respond_to? :to_a and other.to_a.size == children.size children.zip(other.to_a).all? { |a, b| a == b } else identifier == other end end
add_value(value)
click to toggle source
# File lib/cc/yaml/nodes/sequence.rb, line 118 def add_value(value) added = with_value(self) added.add_value!(value) added end
add_value!(value)
click to toggle source
# File lib/cc/yaml/nodes/sequence.rb, line 124 def add_value!(value) children.concat(with_value(value).children) end
allow_child?(*)
click to toggle source
# File lib/cc/yaml/nodes/sequence.rb, line 49 def allow_child?(*) true end
deep_verify()
click to toggle source
Calls superclass method
CC::Yaml::Nodes::Node#deep_verify
# File lib/cc/yaml/nodes/sequence.rb, line 97 def deep_verify @children.each(&:deep_verify) super end
each_scalar(type = nil, &block)
click to toggle source
# File lib/cc/yaml/nodes/sequence.rb, line 102 def each_scalar(type = nil, &block) return enum_for(:each_scalar, type) unless block @children.each { |c| c.each_scalar(type, &block) } end
empty?()
click to toggle source
# File lib/cc/yaml/nodes/sequence.rb, line 68 def empty? @children.empty? end
identifier()
click to toggle source
# File lib/cc/yaml/nodes/sequence.rb, line 80 def identifier @children.size == 1 ? @children.first : @children end
inspect()
click to toggle source
# File lib/cc/yaml/nodes/sequence.rb, line 72 def inspect identifier.inspect end
nested_warnings(*prefix)
click to toggle source
Calls superclass method
CC::Yaml::Nodes::Node#nested_warnings
# File lib/cc/yaml/nodes/sequence.rb, line 53 def nested_warnings(*prefix) @children.inject(super) do |list, value| list = value.nested_warnings(*prefix) + list end end
prepare()
click to toggle source
# File lib/cc/yaml/nodes/sequence.rb, line 17 def prepare @children = [] end
to_s()
click to toggle source
# File lib/cc/yaml/nodes/sequence.rb, line 76 def to_s identifier.to_s end
verify()
click to toggle source
Calls superclass method
CC::Yaml::Nodes::Node#verify
# File lib/cc/yaml/nodes/sequence.rb, line 84 def verify verify_children super end
verify_children()
click to toggle source
# File lib/cc/yaml/nodes/sequence.rb, line 89 def verify_children @children.delete_if do |child| next unless child.errors? child.errors.each { |message| error(message) } true end end
visit_child(visitor, value)
click to toggle source
# File lib/cc/yaml/nodes/sequence.rb, line 33 def visit_child(visitor, value) child = if self.class.type self.class.type.new(self) else visitor.node_wrapper_class(value).new(self) end visitor.accept(child, value) if allow_child?(child) @children << child else warning("Discarding invalid value for %s: %s", self.class, child.value.inspect) end end
visit_mapping(visitor, value)
click to toggle source
# File lib/cc/yaml/nodes/sequence.rb, line 29 def visit_mapping(visitor, value) visit_child(visitor, value) end
visit_scalar(visitor, type, value, implicit = true)
click to toggle source
# File lib/cc/yaml/nodes/sequence.rb, line 25 def visit_scalar(visitor, type, value, implicit = true) visit_child(visitor, value) if type != :null end
visit_sequence(visitor, value)
click to toggle source
# File lib/cc/yaml/nodes/sequence.rb, line 21 def visit_sequence(visitor, value) visitor.apply_sequence(self, value) end
with_value(value)
click to toggle source
# File lib/cc/yaml/nodes/sequence.rb, line 107 def with_value(value) return value.dup if value.is_a? self.class value = value.children if value.is_a? Sequence value = value.value while value.is_a? Scalar Parser::Ruby.new(Array(value)).parse self.class.new(parent) end
with_value!(value)
click to toggle source
# File lib/cc/yaml/nodes/sequence.rb, line 114 def with_value!(value) children.replace with_value(value).children end
Protected Instance Methods
dup_values()
click to toggle source
# File lib/cc/yaml/nodes/sequence.rb, line 130 def dup_values @children = @children.map { |child| child.dup } self end