Class: OsDetector
- Inherits:
-
Object
- Object
- OsDetector
- Includes:
- Singleton
- Defined in:
- lib/framework/detector/os_detector.rb
Instance Attribute Summary collapse
-
#hierarchy ⇒ Object
readonly
Returns the value of attribute hierarchy.
-
#identifier ⇒ Object
readonly
Returns the value of attribute identifier.
-
#version ⇒ Object
readonly
Returns the value of attribute version.
Instance Method Summary collapse
- #detect ⇒ Object
-
#initialize(*_args) ⇒ OsDetector
constructor
A new instance of OsDetector.
Constructor Details
#initialize(*_args) ⇒ OsDetector
Returns a new instance of OsDetector.
10 11 12 13 |
# File 'lib/framework/detector/os_detector.rb', line 10 def initialize(*_args) @identifier = detect @hierarchy = create_hierarchy(@identifier) end |
Instance Attribute Details
#hierarchy ⇒ Object (readonly)
Returns the value of attribute hierarchy.
8 9 10 |
# File 'lib/framework/detector/os_detector.rb', line 8 def hierarchy @hierarchy end |
#identifier ⇒ Object (readonly)
Returns the value of attribute identifier.
8 9 10 |
# File 'lib/framework/detector/os_detector.rb', line 8 def identifier @identifier end |
#version ⇒ Object (readonly)
Returns the value of attribute version.
8 9 10 |
# File 'lib/framework/detector/os_detector.rb', line 8 def version @version end |
Instance Method Details
#detect ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/framework/detector/os_detector.rb', line 15 def detect host_os = RbConfig::CONFIG['host_os'] @identifier = case host_os when /mswin|msys|mingw|cygwin|bccwin|wince|emc/ :windows when /darwin|mac os/ :macosx when /linux/ detect_distro when /solaris|bsd/ :solaris when /aix/ :aix else raise "unknown os: #{host_os.inspect}" end end |