1##
2# Inline keeps track of markup and labels to create proper links.
3
4class RDoc::RD::Inline
5
6  ##
7  # The text of the reference
8
9  attr_reader :reference
10
11  ##
12  # The markup of this reference in RDoc format
13
14  attr_reader :rdoc
15
16  ##
17  # Creates a new Inline for +rdoc+ and +reference+.
18  #
19  # +rdoc+ may be another Inline or a String.  If +reference+ is not given it
20  # will use the text from +rdoc+.
21
22  def self.new rdoc, reference = rdoc
23    if self === rdoc and reference.equal? rdoc then
24      rdoc
25    else
26      super
27    end
28  end
29
30  ##
31  # Initializes the Inline with +rdoc+ and +inline+
32
33  def initialize rdoc, reference # :not-new:
34    @reference = reference.equal?(rdoc) ? reference.dup : reference
35
36    # unpack
37    @reference = @reference.reference if self.class === @reference
38    @rdoc      = rdoc
39  end
40
41  def == other # :nodoc:
42    self.class === other and
43      @reference == other.reference and @rdoc == other.rdoc
44  end
45
46  ##
47  # Appends +more+ to this inline.  +more+ may be a String or another Inline.
48
49  def append more
50    case more
51    when String then
52      @reference << more
53      @rdoc      << more
54    when RDoc::RD::Inline then
55      @reference << more.reference
56      @rdoc      << more.rdoc
57    else
58      raise "unknown thingy #{more}"
59    end
60
61    self
62  end
63
64  def inspect # :nodoc:
65    "(inline: #{self})"
66  end
67
68  alias to_s rdoc # :nodoc:
69
70end
71
72