Class: PGit::Project::InteractiveAdder
- Inherits:
-
Object
- Object
- PGit::Project::InteractiveAdder
- Extended by:
- Forwardable
- Defined in:
- lib/pgit/project/interactive_adder.rb
Instance Attribute Summary collapse
-
#project ⇒ Object
readonly
Returns the value of attribute project.
Instance Method Summary collapse
- #execute! ⇒ Object
- #get_projects ⇒ Object
-
#initialize(project) ⇒ InteractiveAdder
constructor
A new instance of InteractiveAdder.
Constructor Details
permalink #initialize(project) ⇒ InteractiveAdder
Returns a new instance of InteractiveAdder.
12 13 14 |
# File 'lib/pgit/project/interactive_adder.rb', line 12 def initialize(project) @project = project end |
Instance Attribute Details
permalink #project ⇒ Object (readonly)
Returns the value of attribute project.
10 11 12 |
# File 'lib/pgit/project/interactive_adder.rb', line 10 def project @project end |
Instance Method Details
permalink #execute! ⇒ Object
[View source]
16 17 18 19 20 21 22 23 |
# File 'lib/pgit/project/interactive_adder.rb', line 16 def execute! if project.api_token == :no_api_token_given puts "What's the project api_token?" project.api_token = STDIN.gets.chomp end get_projects end |
permalink #get_projects ⇒ Object
[View source]
25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/pgit/project/interactive_adder.rb', line 25 def get_projects projects = PGit::Pivotal::Projects.new(api_token: project.api_token).get! question = Interactive::Question.new do |q| q.question = "Which project do you want to associate with the working directory?" q. = [projects] q.columns = [:index, :name] end question.ask do |response| if response.whole_number? project.id = projects[response.to_i].id end end end |