Class: Coradoc::Markdown::Serializer::Strategies::Autolink::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/coradoc/markdown/serializer/strategies/autolink/base.rb

Overview

A link whose text equals its URL is a bare URL. Each strategy decides how to format it. ‘applies?` is checked first; if no strategy applies, the caller falls back to standard link syntax.

Adding a new autolink form = adding one file + one entry in Registry::MODES. No call-site changes — Open/Closed.

Direct Known Subclasses

Angle, None

Class Method Summary collapse

Class Method Details

.applies?(_url, _text, _ctx) ⇒ Boolean

Returns:

  • (Boolean)

Raises:

  • (NotImplementedError)


16
17
18
# File 'lib/coradoc/markdown/serializer/strategies/autolink/base.rb', line 16

def applies?(_url, _text, _ctx)
  raise NotImplementedError
end

.mode_nameObject



24
25
26
# File 'lib/coradoc/markdown/serializer/strategies/autolink/base.rb', line 24

def mode_name
  name.split('::').last.gsub(/([a-z\d])([A-Z])/, '\1_\2').downcase.to_sym
end

.render(_url, _text, _ctx) ⇒ Object

Raises:

  • (NotImplementedError)


20
21
22
# File 'lib/coradoc/markdown/serializer/strategies/autolink/base.rb', line 20

def render(_url, _text, _ctx)
  raise NotImplementedError
end