summaryrefslogtreecommitdiff
path: root/jni/ruby/lib/rdoc/rd/inline.rb
diff options
context:
space:
mode:
authorJari Vetoniemi <jari.vetoniemi@indooratlas.com>2020-03-16 18:49:26 +0900
committerJari Vetoniemi <jari.vetoniemi@indooratlas.com>2020-03-30 00:39:06 +0900
commitfcbf63e62c627deae76c1b8cb8c0876c536ed811 (patch)
tree64cb17de3f41a2b6fef2368028fbd00349946994 /jni/ruby/lib/rdoc/rd/inline.rb
Fresh start
Diffstat (limited to 'jni/ruby/lib/rdoc/rd/inline.rb')
-rw-r--r--jni/ruby/lib/rdoc/rd/inline.rb71
1 files changed, 71 insertions, 0 deletions
diff --git a/jni/ruby/lib/rdoc/rd/inline.rb b/jni/ruby/lib/rdoc/rd/inline.rb
new file mode 100644
index 0000000..ee724fb
--- /dev/null
+++ b/jni/ruby/lib/rdoc/rd/inline.rb
@@ -0,0 +1,71 @@
+##
+# Inline keeps track of markup and labels to create proper links.
+
+class RDoc::RD::Inline
+
+ ##
+ # The text of the reference
+
+ attr_reader :reference
+
+ ##
+ # The markup of this reference in RDoc format
+
+ attr_reader :rdoc
+
+ ##
+ # Creates a new Inline for +rdoc+ and +reference+.
+ #
+ # +rdoc+ may be another Inline or a String. If +reference+ is not given it
+ # will use the text from +rdoc+.
+
+ def self.new rdoc, reference = rdoc
+ if self === rdoc and reference.equal? rdoc then
+ rdoc
+ else
+ super
+ end
+ end
+
+ ##
+ # Initializes the Inline with +rdoc+ and +inline+
+
+ def initialize rdoc, reference # :not-new:
+ @reference = reference.equal?(rdoc) ? reference.dup : reference
+
+ # unpack
+ @reference = @reference.reference if self.class === @reference
+ @rdoc = rdoc
+ end
+
+ def == other # :nodoc:
+ self.class === other and
+ @reference == other.reference and @rdoc == other.rdoc
+ end
+
+ ##
+ # Appends +more+ to this inline. +more+ may be a String or another Inline.
+
+ def append more
+ case more
+ when String then
+ @reference << more
+ @rdoc << more
+ when RDoc::RD::Inline then
+ @reference << more.reference
+ @rdoc << more.rdoc
+ else
+ raise "unknown thingy #{more}"
+ end
+
+ self
+ end
+
+ def inspect # :nodoc:
+ "(inline: #{self})"
+ end
+
+ alias to_s rdoc # :nodoc:
+
+end
+