Class: Procps::PS::CommandBuilder
- Inherits:
-
Object
- Object
- Procps::PS::CommandBuilder
- Defined in:
- lib/procps/ps/command_builder.rb
Overview
Builds complete ps
shell command before execution.
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(ps) ⇒ CommandBuilder
constructor
A new instance of CommandBuilder.
- #modifiers ⇒ Object
- #options ⇒ Object
Constructor Details
#initialize(ps) ⇒ CommandBuilder
Returns a new instance of CommandBuilder.
7 8 9 |
# File 'lib/procps/ps/command_builder.rb', line 7 def initialize(ps) @ps = ps end |
Instance Method Details
#call ⇒ Object
11 12 13 |
# File 'lib/procps/ps/command_builder.rb', line 11 def call [@ps.bin_path, *modifiers, *].compact end |
#modifiers ⇒ Object
15 16 17 |
# File 'lib/procps/ps/command_builder.rb', line 15 def modifiers @modifiers ||= @ps.modifiers.size > 0 ? @ps.modifiers.to_a * "" : nil end |
#options ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/procps/ps/command_builder.rb', line 19 def @options ||= begin @ps..flat_map do |opt, value| case value when false then nil when true then normalize_option_key(opt) else [normalize_option_key(opt), normalize_option_value(value)] end end end end |