Class: LicenseAcceptance::Strategy::Argument
- Defined in:
- lib/license_acceptance/strategy/argument.rb
Overview
Look for acceptance values in the ARGV
Constant Summary collapse
- FLAG =
"--chef-license".freeze
Instance Attribute Summary collapse
-
#argv ⇒ Object
readonly
Returns the value of attribute argv.
Instance Method Summary collapse
- #accepted? ⇒ Boolean
-
#initialize(argv) ⇒ Argument
constructor
A new instance of Argument.
- #no_persist? ⇒ Boolean
- #silent? ⇒ Boolean
- #value ⇒ Object
- #value? ⇒ Boolean
Constructor Details
#initialize(argv) ⇒ Argument
Returns a new instance of Argument.
13 14 15 |
# File 'lib/license_acceptance/strategy/argument.rb', line 13 def initialize(argv) @argv = argv end |
Instance Attribute Details
#argv ⇒ Object (readonly)
Returns the value of attribute argv.
11 12 13 |
# File 'lib/license_acceptance/strategy/argument.rb', line 11 def argv @argv end |
Instance Method Details
#accepted? ⇒ Boolean
17 18 19 |
# File 'lib/license_acceptance/strategy/argument.rb', line 17 def accepted? String(value).downcase == ACCEPT end |
#no_persist? ⇒ Boolean
25 26 27 |
# File 'lib/license_acceptance/strategy/argument.rb', line 25 def no_persist? String(value).downcase == ACCEPT_NO_PERSIST end |
#silent? ⇒ Boolean
21 22 23 |
# File 'lib/license_acceptance/strategy/argument.rb', line 21 def silent? String(value).downcase == ACCEPT_SILENT end |
#value ⇒ Object
33 34 35 36 37 38 39 40 41 42 |
# File 'lib/license_acceptance/strategy/argument.rb', line 33 def value match = argv.detect { |s| s.start_with?("#{FLAG}=") } return match.split("=").last if match argv.each_cons(2) do |arg, value| return value if arg == FLAG end nil end |
#value? ⇒ Boolean
29 30 31 |
# File 'lib/license_acceptance/strategy/argument.rb', line 29 def value? argv.any? { |s| s == FLAG || s.start_with?("#{FLAG}=") } end |