Class: Inspec::Resources::OsEnv
- Inherits:
-
Object
- Object
- Inspec::Resources::OsEnv
- Defined in:
- lib/resources/os_env.rb
Instance Attribute Summary collapse
-
#content ⇒ Object
readonly
Returns the value of attribute content.
Instance Method Summary collapse
-
#initialize(env = nil) ⇒ OsEnv
constructor
A new instance of OsEnv.
- #split ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(env = nil) ⇒ OsEnv
Returns a new instance of OsEnv.
27 28 29 30 31 |
# File 'lib/resources/os_env.rb', line 27 def initialize(env = nil) @osenv = env @content = nil @content = value_for(env) unless env.nil? end |
Instance Attribute Details
#content ⇒ Object (readonly)
Returns the value of attribute content.
26 27 28 |
# File 'lib/resources/os_env.rb', line 26 def content @content end |
Instance Method Details
#split ⇒ Object
33 34 35 36 37 38 39 40 |
# File 'lib/resources/os_env.rb', line 33 def split # we can't take advantage of `File::PATH_SEPARATOR` as code is # evaluated on the host machine path_separator = inspec.os.windows? ? ';' : ':' # -1 is required to catch cases like dir1::dir2: # where we have a trailing : @content.nil? ? [] : @content.split(path_separator, -1) end |
#to_s ⇒ Object
42 43 44 45 46 47 48 |
# File 'lib/resources/os_env.rb', line 42 def to_s if @osenv.nil? 'Environment variables' else "Environment variable #{@osenv}" end end |