Class: TTY::Link::PlainLink Private
- Inherits:
-
Object
- Object
- TTY::Link::PlainLink
- Defined in:
- lib/tty/link/plain_link.rb
Overview
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
Responsible for converting a URL to a plain terminal link
Instance Method Summary collapse
-
#initialize(name, url, template) ⇒ PlainLink
constructor
Create a PlainLink instance.
-
#to_s ⇒ String
Convert this link to a plain string.
Constructor Details
#initialize(name, url, template) ⇒ PlainLink
Create a TTY::Link::PlainLink instance
31 32 33 34 35 |
# File 'lib/tty/link/plain_link.rb', line 31 def initialize(name, url, template) @name = name @url = url @template = template end |
Instance Method Details
#to_s ⇒ String
Convert this link to a plain string
46 47 48 49 |
# File 'lib/tty/link/plain_link.rb', line 46 def to_s replacements = {":name" => @name, ":url" => @url} @template.gsub(REPLACEMENT_TOKENS_PATTERN, replacements) end |