Class: Launchy::Detect::HostOsFamily

Inherits:
Object
  • Object
show all
Extended by:
Launchy::DescendantTracker
Defined in:
lib/launchy/detect/host_os_family.rb

Overview

Detect the current host os family

If the current host familiy cannot be detected then return HostOsFamily::Unknown

Direct Known Subclasses

Cygwin, Darwin, Nix, Windows

Defined Under Namespace

Classes: Cygwin, Darwin, Nix, NotFoundError, Windows

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Launchy::DescendantTracker

children, find_child, inherited

Constructor Details

#initialize(host_os = HostOs.new) ⇒ HostOsFamily

Returns a new instance of HostOsFamily.



44
45
46
# File 'lib/launchy/detect/host_os_family.rb', line 44

def initialize(host_os = HostOs.new)
  @host_os = host_os
end

Instance Attribute Details

#host_osObject (readonly)

Returns the value of attribute host_os.



42
43
44
# File 'lib/launchy/detect/host_os_family.rb', line 42

def host_os
  @host_os
end

Class Method Details

.cygwin?Boolean

Returns:

  • (Boolean)


37
38
39
# File 'lib/launchy/detect/host_os_family.rb', line 37

def cygwin?
  self == Cygwin
end

.darwin?Boolean

Returns:

  • (Boolean)


29
30
31
# File 'lib/launchy/detect/host_os_family.rb', line 29

def darwin?
  self == Darwin
end

.detect(host_os = HostOs.new) ⇒ Object

Raises:



14
15
16
17
18
19
# File 'lib/launchy/detect/host_os_family.rb', line 14

def detect(host_os = HostOs.new)
  found = find_child(:matches?, host_os)
  return found.new(host_os) if found

  raise NotFoundError, "Unknown OS family for host os '#{host_os}'. #{Launchy.bug_report_message}"
end

.matches?(host_os) ⇒ Boolean

Returns:

  • (Boolean)


21
22
23
# File 'lib/launchy/detect/host_os_family.rb', line 21

def matches?(host_os)
  matching_regex.match(host_os.to_s)
end

.nix?Boolean

Returns:

  • (Boolean)


33
34
35
# File 'lib/launchy/detect/host_os_family.rb', line 33

def nix?
  self == Nix
end

.windows?Boolean

Returns:

  • (Boolean)


25
26
27
# File 'lib/launchy/detect/host_os_family.rb', line 25

def windows?
  self == Windows
end

Instance Method Details

#cygwin?Boolean

Returns:

  • (Boolean)


60
61
62
# File 'lib/launchy/detect/host_os_family.rb', line 60

def cygwin?
  self.class.cygwin?
end

#darwin?Boolean

Returns:

  • (Boolean)


52
53
54
# File 'lib/launchy/detect/host_os_family.rb', line 52

def darwin?
  self.class.darwin?
end

#nix?Boolean

Returns:

  • (Boolean)


56
57
58
# File 'lib/launchy/detect/host_os_family.rb', line 56

def nix?
  self.class.nix?
end

#windows?Boolean

Returns:

  • (Boolean)


48
49
50
# File 'lib/launchy/detect/host_os_family.rb', line 48

def windows?
  self.class.windows?
end