Class: Utopia::Project::Linkify
- Inherits:
-
Decode::Syntax::Rewriter
- Object
- Decode::Syntax::Rewriter
- Utopia::Project::Linkify
- Defined in:
- lib/utopia/project/linkify.rb
Instance Method Summary collapse
- #apply(output = XRB::Builder.new) ⇒ Object
-
#initialize(base, language, text) ⇒ Linkify
constructor
A new instance of Linkify.
- #link_to(definition, text) ⇒ Object
- #text_for(range) ⇒ Object
Constructor Details
#initialize(base, language, text) ⇒ Linkify
Returns a new instance of Linkify.
12 13 14 15 16 17 |
# File 'lib/utopia/project/linkify.rb', line 12 def initialize(base, language, text) @base = base @language = language super(text) end |
Instance Method Details
#apply(output = XRB::Builder.new) ⇒ Object
33 34 35 36 37 38 39 |
# File 'lib/utopia/project/linkify.rb', line 33 def apply(output = XRB::Builder.new) output.inline("code", class: "language-#{@language.name}") do super end return output.to_str end |
#link_to(definition, text) ⇒ Object
25 26 27 28 29 30 31 |
# File 'lib/utopia/project/linkify.rb', line 25 def link_to(definition, text) XRB::Builder.fragment do |builder| builder.inline("a", href: @base.link_for(definition), title: definition.qualified_name) do builder.text(text) end end end |
#text_for(range) ⇒ Object
19 20 21 22 23 |
# File 'lib/utopia/project/linkify.rb', line 19 def text_for(range) text = super(range) return XRB::Strings.to_html(text) end |