Class: RDoc::RD::Inline

Inherits:
Object
  • Object
show all
Defined in:
lib/rdoc/rd/inline.rb

Overview

Inline keeps track of markup and labels to create proper links.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(rdoc, reference) ⇒ Inline

Initializes the Inline with rdoc and inline


33
34
35
36
37
38
39
# File 'lib/rdoc/rd/inline.rb', line 33

def initialize rdoc, reference # :not-new:
  @reference = reference.equal?(rdoc) ? reference.dup : reference

  # unpack
  @reference = @reference.reference if self.class === @reference
  @rdoc      = rdoc
end

Instance Attribute Details

#rdocObject (readonly) Also known as: to_s

The markup of this reference in RDoc format


14
15
16
# File 'lib/rdoc/rd/inline.rb', line 14

def rdoc
  @rdoc
end

#referenceObject (readonly)

The text of the reference


9
10
11
# File 'lib/rdoc/rd/inline.rb', line 9

def reference
  @reference
end

Class Method Details

.new(rdoc, reference = rdoc) ⇒ Object

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.


22
23
24
25
26
27
28
# File 'lib/rdoc/rd/inline.rb', line 22

def self.new rdoc, reference = rdoc
  if self === rdoc and reference.equal? rdoc then
    rdoc
  else
    super
  end
end

Instance Method Details

#==(other) ⇒ Object

:nodoc:


41
42
43
44
# File 'lib/rdoc/rd/inline.rb', line 41

def == other # :nodoc:
  self.class === other and
    @reference == other.reference and @rdoc == other.rdoc
end

#append(more) ⇒ Object

Appends more to this inline. more may be a String or another Inline.


49
50
51
52
53
54
55
56
57
58
59
60
61
62
# File 'lib/rdoc/rd/inline.rb', line 49

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

#inspectObject

:nodoc:


64
65
66
# File 'lib/rdoc/rd/inline.rb', line 64

def inspect # :nodoc:
  "(inline: #{self})"
end