Class: Rly::Commands::Open
- Inherits:
-
Rly::Command
- Object
- Rly::Command
- Rly::Commands::Open
- Defined in:
- lib/rly/commands/open.rb
Instance Method Summary collapse
- #execute(input: $stdin, output: $stdout) ⇒ Object
-
#initialize(name, options) ⇒ Open
constructor
A new instance of Open.
- #open(url) ⇒ Object
Methods inherited from Rly::Command
#command, #cursor, #editor, #exec_exist?, #generator, #pager, #platform, #prompt, #screen, #which
Constructor Details
#initialize(name, options) ⇒ Open
Returns a new instance of Open.
9 10 11 12 |
# File 'lib/rly/commands/open.rb', line 9 def initialize(name, ) @name = name @options = end |
Instance Method Details
#execute(input: $stdin, output: $stdout) ⇒ Object
14 15 16 17 18 19 20 21 |
# File 'lib/rly/commands/open.rb', line 14 def execute(input: $stdin, output: $stdout) shortcuts = Rly::Shortcuts.new if shortcuts.exist?(@name) open(shortcuts.find(@name)) else output.puts "can't find shortcut with name #{@name}" end end |
#open(url) ⇒ Object
23 24 25 26 27 28 29 30 31 |
# File 'lib/rly/commands/open.rb', line 23 def open(url) if RbConfig::CONFIG['host_os'] =~ /mswin|mingw|cygwin/ system "start #{url}" elsif RbConfig::CONFIG['host_os'] =~ /darwin/ system "open #{url}" elsif RbConfig::CONFIG['host_os'] =~ /linux|bsd/ system "xdg-open #{url}" end end |