Class: Assemblyline::Ruby::Platform

Inherits:
Object
  • Object
show all
Defined in:
lib/assemblyline/ruby/platform.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#idObject (readonly)

Returns the value of attribute id.



16
17
18
# File 'lib/assemblyline/ruby/platform.rb', line 16

def id
  @id
end

#likeObject (readonly)

Returns the value of attribute like.



16
17
18
# File 'lib/assemblyline/ruby/platform.rb', line 16

def like
  @like
end

#versionObject (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_sObject



18
19
20
# File 'lib/assemblyline/ruby/platform.rb', line 18

def to_s
  @pretty
end