Class: TerminalLink::Link
- Inherits:
-
Object
- Object
- TerminalLink::Link
- Defined in:
- lib/terminal_link.rb
Instance Attribute Summary collapse
-
#text ⇒ Object
Returns the value of attribute text.
-
#url ⇒ Object
Returns the value of attribute url.
Instance Method Summary collapse
-
#initialize(url = nil, text = nil) ⇒ Link
constructor
A new instance of Link.
- #print ⇒ Object
Constructor Details
#initialize(url = nil, text = nil) ⇒ Link
Returns a new instance of Link.
5 6 7 8 |
# File 'lib/terminal_link.rb', line 5 def initialize(url=nil, text=nil) @text = text @url = url end |
Instance Attribute Details
#text ⇒ Object
Returns the value of attribute text.
3 4 5 |
# File 'lib/terminal_link.rb', line 3 def text @text end |
#url ⇒ Object
Returns the value of attribute url.
3 4 5 |
# File 'lib/terminal_link.rb', line 3 def url @url end |
Instance Method Details
#print ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/terminal_link.rb', line 10 def print # template = "echo -e '\e]8;;http://example.com\e\\This is a link\e]8;;\e\\'" default_link = "https://gist.github.com/egmontkob/eb114294efbcd5adb1944c9f3cb5feda" if url && !text system("echo", "\e]8;;#{@url}\e\\#{@url}\e]8;;\e\\") elsif url && text system("echo", "\e]8;;#{@url}\e\\#{@text}\e]8;;\e\\") elsif !url && !text system("echo", "\e]8;;#{default_link}\e\\Hyperlinks in terminal emulators\e]8;;\e\\") #`echo -e '\e]8;;#{default_link}}\e\\"Hyperlinks in terminal emulators\e]8;;\e\\'` end end |