Class: Reviewer::Command::String::Env
- Inherits:
-
Object
- Object
- Reviewer::Command::String::Env
- Defined in:
- lib/reviewer/command/string/env.rb
Overview
Assembles tool environment variables into a single string or array
Instance Attribute Summary collapse
-
#env_pairs ⇒ Object
readonly
Returns the value of attribute env_pairs.
Instance Method Summary collapse
-
#initialize(env_pairs) ⇒ self
constructor
Creates an instance of env variables for a tool to help generate the command string.
-
#to_a ⇒ Array<String, nil>
Converts environment variables to an array of KEY=value strings.
-
#to_s ⇒ String
Converts environment variables to a space-separated string.
Constructor Details
#initialize(env_pairs) ⇒ self
Creates an instance of env variables for a tool to help generate the command string
14 15 16 |
# File 'lib/reviewer/command/string/env.rb', line 14 def initialize(env_pairs) @env_pairs = env_pairs end |
Instance Attribute Details
#env_pairs ⇒ Object (readonly)
Returns the value of attribute env_pairs.
8 9 10 |
# File 'lib/reviewer/command/string/env.rb', line 8 def env_pairs @env_pairs end |
Instance Method Details
#to_a ⇒ Array<String, nil>
Converts environment variables to an array of KEY=value strings
28 29 30 |
# File 'lib/reviewer/command/string/env.rb', line 28 def to_a env_pairs.map { |key, value| env(key, value) } end |
#to_s ⇒ String
Converts environment variables to a space-separated string
21 22 23 |
# File 'lib/reviewer/command/string/env.rb', line 21 def to_s to_a.compact.join(' ') end |