Class: LearnConfig::Setup
- Inherits:
-
Object
- Object
- LearnConfig::Setup
- Defined in:
- lib/learn_config/setup.rb
Instance Attribute Summary collapse
-
#args ⇒ Object
readonly
Returns the value of attribute args.
-
#netrc ⇒ Object
readonly
Returns the value of attribute netrc.
-
#reset ⇒ Object
readonly
Returns the value of attribute reset.
-
#set_dir ⇒ Object
readonly
Returns the value of attribute set_dir.
-
#whoami ⇒ Object
readonly
Returns the value of attribute whoami.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(args) ⇒ Setup
constructor
A new instance of Setup.
- #run ⇒ Object
Constructor Details
#initialize(args) ⇒ Setup
Returns a new instance of Setup.
9 10 11 12 13 14 15 |
# File 'lib/learn_config/setup.rb', line 9 def initialize(args) @args = args @netrc = LearnConfig::NetrcInteractor.new @reset = !!args.include?('--reset') @whoami = !!args.include?('--whoami') @set_dir = !!args.include?('--set-directory') end |
Instance Attribute Details
#args ⇒ Object (readonly)
Returns the value of attribute args.
3 4 5 |
# File 'lib/learn_config/setup.rb', line 3 def args @args end |
#netrc ⇒ Object (readonly)
Returns the value of attribute netrc.
3 4 5 |
# File 'lib/learn_config/setup.rb', line 3 def netrc @netrc end |
#reset ⇒ Object (readonly)
Returns the value of attribute reset.
3 4 5 |
# File 'lib/learn_config/setup.rb', line 3 def reset @reset end |
#set_dir ⇒ Object (readonly)
Returns the value of attribute set_dir.
3 4 5 |
# File 'lib/learn_config/setup.rb', line 3 def set_dir @set_dir end |
#whoami ⇒ Object (readonly)
Returns the value of attribute whoami.
3 4 5 |
# File 'lib/learn_config/setup.rb', line 3 def whoami @whoami end |
Class Method Details
.run(args) ⇒ Object
5 6 7 |
# File 'lib/learn_config/setup.rb', line 5 def self.run(args) new(args).run end |
Instance Method Details
#run ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/learn_config/setup.rb', line 17 def run if reset args.delete('--reset') confirm_and_reset! elsif whoami args.delete('--whoami') check_config whoami? elsif set_dir args.delete('--set-directory') check_config set_directory! else check_config end end |