Class: Reviewer::Command::String::Flags

Inherits:
Object
  • Object
show all
Defined in:
lib/reviewer/command/string/flags.rb

Overview

Translates tool flag settings from the tool’s configuration values into a single string or

array that can be used to generate the command string

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(flag_pairs) ⇒ self

Creates an instance of command-string friendly flags

Parameters:

  • flag_pairs (Hash)

    the flags (keys) and their values



15
16
17
# File 'lib/reviewer/command/string/flags.rb', line 15

def initialize(flag_pairs)
  @flag_pairs = flag_pairs
end

Instance Attribute Details

#flag_pairsObject (readonly)

Returns the value of attribute flag_pairs.



9
10
11
# File 'lib/reviewer/command/string/flags.rb', line 9

def flag_pairs
  @flag_pairs
end

Instance Method Details

#to_aArray<String>

Creates an array of all flag name/value pairs

Returns:

  • (Array<String>)

    array of all flag strings to use to when running the command



29
30
31
32
33
# File 'lib/reviewer/command/string/flags.rb', line 29

def to_a
  flags = []
  flag_pairs.each { |key, value| flags << flag(key, value) }
  flags
end

#to_sString

Creates a string-friendly format to use in a command

Returns:

  • (String)

    a string of flags that can be safely passed to a command



22
23
24
# File 'lib/reviewer/command/string/flags.rb', line 22

def to_s
  to_a.join(' ')
end