Class: Semaph::Shells::Organisation::ProjectsSelectCommand
- Inherits:
-
Object
- Object
- Semaph::Shells::Organisation::ProjectsSelectCommand
- Defined in:
- lib/semaph/shells/organisation/projects_select_command.rb
Instance Attribute Summary collapse
-
#help ⇒ Object
readonly
Returns the value of attribute help.
-
#usage ⇒ Object
readonly
Returns the value of attribute usage.
Instance Method Summary collapse
- #completion(text) ⇒ Object
- #execute(name) ⇒ Object
-
#initialize(project_collection) ⇒ ProjectsSelectCommand
constructor
A new instance of ProjectsSelectCommand.
Constructor Details
#initialize(project_collection) ⇒ ProjectsSelectCommand
Returns a new instance of ProjectsSelectCommand.
9 10 11 12 13 |
# File 'lib/semaph/shells/organisation/projects_select_command.rb', line 9 def initialize(project_collection) @project_collection = project_collection @usage = "<project>" @help = "choose project" end |
Instance Attribute Details
#help ⇒ Object (readonly)
Returns the value of attribute help.
7 8 9 |
# File 'lib/semaph/shells/organisation/projects_select_command.rb', line 7 def help @help end |
#usage ⇒ Object (readonly)
Returns the value of attribute usage.
7 8 9 |
# File 'lib/semaph/shells/organisation/projects_select_command.rb', line 7 def usage @usage end |
Instance Method Details
#completion(text) ⇒ Object
15 16 17 |
# File 'lib/semaph/shells/organisation/projects_select_command.rb', line 15 def completion(text) @project_collection.all.map(&:name).grep(/^#{text}/).sort end |
#execute(name) ⇒ Object
19 20 21 22 23 24 25 26 27 28 |
# File 'lib/semaph/shells/organisation/projects_select_command.rb', line 19 def execute(name) selected_project = @project_collection.all.find { |project| project.name == name } unless selected_project puts "There is no project called #{name}" return end ::Semaph::Shells::Project::ProjectShell.new(selected_project).push end |