Class: Assemblyline::Ruby::Platform
- Inherits:
-
Object
- Object
- Assemblyline::Ruby::Platform
- Defined in:
- lib/assemblyline/ruby/platform.rb
Instance Attribute Summary collapse
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#like ⇒ Object
readonly
Returns the value of attribute like.
-
#version ⇒ Object
readonly
Returns the value of attribute version.
Instance Method Summary collapse
-
#initialize(path = "/etc/os-release") ⇒ Platform
constructor
A new instance of Platform.
- #to_s ⇒ Object
Constructor Details
#initialize(path = "/etc/os-release") ⇒ Platform
Returns a new instance of Platform.
4 5 6 7 8 9 10 11 12 13 14 |
# File 'lib/assemblyline/ruby/platform.rb', line 4 def initialize(path = "/etc/os-release") release = Hash[ File.read(path) .tr("\"", "") .split("\n").map { |row| row.split("=") } ] @id = release["ID"] @like = release["ID_LIKE"] @version = release["VERSION_ID"] @pretty = release["PRETTY_NAME"] end |
Instance Attribute Details
#id ⇒ Object (readonly)
Returns the value of attribute id.
16 17 18 |
# File 'lib/assemblyline/ruby/platform.rb', line 16 def id @id end |
#like ⇒ Object (readonly)
Returns the value of attribute like.
16 17 18 |
# File 'lib/assemblyline/ruby/platform.rb', line 16 def like @like end |
#version ⇒ Object (readonly)
Returns the value of attribute version.
16 17 18 |
# File 'lib/assemblyline/ruby/platform.rb', line 16 def version @version end |
Instance Method Details
#to_s ⇒ Object
18 19 20 |
# File 'lib/assemblyline/ruby/platform.rb', line 18 def to_s @pretty end |