Module: Rickroll

Defined in:
lib/rickroll.rb,
lib/rickroll/version.rb

Constant Summary collapse

VERSION =
"0.0.2"

Class Method Summary collapse

Class Method Details

.has_open?Boolean

Returns:

  • (Boolean)


14
15
16
17
18
# File 'lib/rickroll.rb', line 14

def self.has_open?
  `which open`
  return false unless $?.success?
  `open --help 2>&1`.include? 'Opens with the specified application'
end

.openObject



19
20
21
# File 'lib/rickroll.rb', line 19

def self.open
  has_open? ? open_with_safari : open_with_launchy
end

.open_with_launchyObject



7
8
9
10
# File 'lib/rickroll.rb', line 7

def self.open_with_launchy
  require 'launchy'
  Launchy.open(path)
end

.open_with_safariObject



11
12
13
# File 'lib/rickroll.rb', line 11

def self.open_with_safari
  `open -a Safari #{path.inspect}`
end

.pathObject



4
5
6
# File 'lib/rickroll.rb', line 4

def self.path
  File.expand_path('../../site/index.html', __FILE__)
end