Class: RenderAsMarkdown::Link
- Inherits:
-
Object
- Object
- RenderAsMarkdown::Link
- Defined in:
- lib/render-as-markdown/link.rb
Instance Attribute Summary collapse
-
#hint ⇒ Object
TODO: look up Github in-document link reference and implement it (e.g. “[A Header](#a-header)” ).
-
#text ⇒ Object
TODO: look up Github in-document link reference and implement it (e.g. “[A Header](#a-header)” ).
-
#url ⇒ Object
TODO: look up Github in-document link reference and implement it (e.g. “[A Header](#a-header)” ).
Instance Method Summary collapse
-
#initialize(url, text = nil, hint = nil) ⇒ Link
constructor
A new instance of Link.
- #render ⇒ Object (also: #to_s)
Constructor Details
#initialize(url, text = nil, hint = nil) ⇒ Link
Returns a new instance of Link.
8 9 10 |
# File 'lib/render-as-markdown/link.rb', line 8 def initialize url, text=nil, hint=nil @url, @text, @hint = url.to_s, text.to_s, hint.to_s end |
Instance Attribute Details
#hint ⇒ Object
TODO: look up Github in-document link reference and implement it (e.g. “[A Header](#a-header)” )
6 7 8 |
# File 'lib/render-as-markdown/link.rb', line 6 def hint @hint end |
#text ⇒ Object
TODO: look up Github in-document link reference and implement it (e.g. “[A Header](#a-header)” )
6 7 8 |
# File 'lib/render-as-markdown/link.rb', line 6 def text @text end |
#url ⇒ Object
TODO: look up Github in-document link reference and implement it (e.g. “[A Header](#a-header)” )
6 7 8 |
# File 'lib/render-as-markdown/link.rb', line 6 def url @url end |
Instance Method Details
#render ⇒ Object Also known as: to_s
12 13 14 15 16 |
# File 'lib/render-as-markdown/link.rb', line 12 def render text = @text.empty? ? @url : @text hint = " \"#{@hint}\"" unless @hint.empty? "[#{text}](#{@url}#{hint})" end |