class Interscript::Node::Item::String
Attributes
data[RW]
Public Class Methods
new(data)
click to toggle source
# File lib/interscript/node/item/string.rb, line 3 def initialize data self.data = data end
Public Instance Methods
+(other)
click to toggle source
Calls superclass method
Interscript::Node::Item#+
# File lib/interscript/node/item/string.rb, line 25 def + other if self.data == "" Interscript::Node::Item.try_convert(other) elsif Interscript::Node::Item::String === self && (Interscript::Node::Item::String === other || ::String === other) other = Interscript::Node::Item.try_convert(other) Interscript::Node::Item::String.new(self.data + other.data) else super end end
==(other)
click to toggle source
Calls superclass method
Interscript::Node::Item#==
# File lib/interscript/node/item/string.rb, line 39 def ==(other) super && self.data == other.data end
downcase()
click to toggle source
# File lib/interscript/node/item/string.rb, line 20 def downcase; self.dup.tap { |i| i.data = i.data.downcase }; end
first_string()
click to toggle source
# File lib/interscript/node/item/string.rb, line 16 def first_string self.data end
Also aliased as: nth_string
inspect()
click to toggle source
# File lib/interscript/node/item/string.rb, line 43 def inspect @data.inspect end
max_length()
click to toggle source
# File lib/interscript/node/item/string.rb, line 12 def max_length self.data.length end
to_hash()
click to toggle source
# File lib/interscript/node/item/string.rb, line 7 def to_hash { :class => self.class.to_s, :data => self.data } end
to_html(_)
click to toggle source
# File lib/interscript/visualize/nodes.rb, line 78 def to_html(_) out = "" self.data.each_char do |i| out << "<ruby>" out << "<kbd>#{h i}</kbd>" out << "<rt>#{"%04x" % i.ord}</rt>" out << "</ruby>" end out end
upcase()
click to toggle source
# File lib/interscript/node/item/string.rb, line 21 def upcase; self.dup.tap { |i| i.data = i.data.upcase }; end