Sha256: 7164bcbd29680f0ba4f02923078354e095fe51f8b4cfa476f929039cf9bfb1c5

Contents?: true

Size: 1.38 KB

Versions: 14

Compression:

Stored size: 1.38 KB

Contents

# frozen_string_literal: true
##
# 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

Version data entries

14 entries across 14 versions & 5 rubygems

Version Path
rdoc-6.11.0 lib/rdoc/rd/inline.rb
minato_ruby_api_client-0.2.2 vendor/bundle/ruby/3.2.0/gems/rdoc-6.7.0/lib/rdoc/rd/inline.rb
rdoc-6.10.0 lib/rdoc/rd/inline.rb
rdoc-6.9.1 lib/rdoc/rd/inline.rb
rdoc-6.9.0 lib/rdoc/rd/inline.rb
rdoc-6.8.1 lib/rdoc/rd/inline.rb
rdoc-6.8.0 lib/rdoc/rd/inline.rb
blacklight-spotlight-3.6.0.beta8 vendor/bundle/ruby/3.2.0/gems/rdoc-6.7.0/lib/rdoc/rd/inline.rb
tinymce-rails-7.1.2 vendor/bundle/ruby/3.3.0/gems/rdoc-6.7.0/lib/rdoc/rd/inline.rb
rdoc-6.6.3.1 lib/rdoc/rd/inline.rb
rdoc-6.6.2 lib/rdoc/rd/inline.rb
rdoc-6.6.1 lib/rdoc/rd/inline.rb
honeybadger-5.4.0 vendor/bundle/ruby/3.2.0/gems/rdoc-6.6.0/lib/rdoc/rd/inline.rb
rdoc-6.6.0 lib/rdoc/rd/inline.rb