Class: Decode::Syntax::Link

Inherits:
Match
  • Object
show all
Defined in:
lib/decode/syntax/link.rb

Overview

Represents a link to a definition in the documentation.

Instance Attribute Summary collapse

Attributes inherited from Match

#range

Instance Method Summary collapse

Methods inherited from Match

#<=>, #offset, #size

Constructor Details

#initialize(range, definition) ⇒ Link

Initialize a new link.



16
17
18
19
20
# File 'lib/decode/syntax/link.rb', line 16

def initialize(range, definition)
  @definition = definition
  
  super(range)
end

Instance Attribute Details

#definitionObject (readonly)

Returns the value of attribute definition.



22
23
24
# File 'lib/decode/syntax/link.rb', line 22

def definition
  @definition
end

Instance Method Details

#apply(output, rewriter) ⇒ Object

Apply the link to the output.



27
28
29
30
31
32
33
34
# File 'lib/decode/syntax/link.rb', line 27

def apply(output, rewriter)
  output << rewriter.link_to(
    @definition,
    rewriter.text_for(@range)
  )
  
  return self.size
end