class CSL::TextNode
Attributes
Public Class Methods
Source
# File lib/csl/node.rb, line 562 def create(name, attributes = {}, &block) klass = constantize(name) node = (klass || TextNode).new(attributes, &block) node.nodename = name node end
@override
Source
# File lib/csl/node.rb, line 588 def initialize(argument = '') case when argument.respond_to?(:each_pair) super when argument.respond_to?(:to_s) super({}) @text = argument.to_s yield self if block_given? else raise ArgumentError, "failed to create text node from #{argument.inspect}" end end
TextNodes quack like a string. def_delegators :to_s, *String.instance_methods(false).reject do |m|
m.to_s =~ /^\W|!$|(?:^(?:hash|eql?|to_s|length|size|inspect)$)/
end
String.instance_methods(false).select { |m| m.to_s =~ /!$/ }.each do |m|
define_method(m) do content.send(m) if content.respond_to?(m) end
end
Calls superclass method
CSL::Node::new
Public Instance Methods
Source
# File lib/csl/node.rb, line 601 def initialize_copy(other) super @text = other.text end
Calls superclass method
CSL::Node#initialize_copy
Source
# File lib/csl/node.rb, line 620 def inspect "#<#{[self.class.name, text.inspect, *attribute_assignments].join(' ')}>" end