Class: Gitlab::Triage::CommandBuilders::BaseCommandBuilder
- Inherits:
-
Object
- Object
- Gitlab::Triage::CommandBuilders::BaseCommandBuilder
- Defined in:
- lib/gitlab/triage/command_builders/base_command_builder.rb
Direct Known Subclasses
CcCommandBuilder, CommentCommandBuilder, LabelCommandBuilder, MoveCommandBuilder, StatusCommandBuilder, TextContentBuilder
Instance Attribute Summary collapse
-
#items ⇒ Object
readonly
private
Returns the value of attribute items.
-
#network ⇒ Object
readonly
private
Returns the value of attribute network.
-
#resource ⇒ Object
readonly
private
Returns the value of attribute resource.
Instance Method Summary collapse
- #build_command ⇒ Object
- #content_string ⇒ Object private
-
#initialize(items, resource: nil, network: nil) ⇒ BaseCommandBuilder
constructor
A new instance of BaseCommandBuilder.
- #separator ⇒ Object private
- #slash_command_string ⇒ Object private
Constructor Details
#initialize(items, resource: nil, network: nil) ⇒ BaseCommandBuilder
Returns a new instance of BaseCommandBuilder.
5 6 7 8 9 10 |
# File 'lib/gitlab/triage/command_builders/base_command_builder.rb', line 5 def initialize(items, resource: nil, network: nil) @items = Array.wrap(items) @items.delete('') @resource = resource&.with_indifferent_access @network = network end |
Instance Attribute Details
#items ⇒ Object (readonly, private)
Returns the value of attribute items.
22 23 24 |
# File 'lib/gitlab/triage/command_builders/base_command_builder.rb', line 22 def items @items end |
#network ⇒ Object (readonly, private)
Returns the value of attribute network.
22 23 24 |
# File 'lib/gitlab/triage/command_builders/base_command_builder.rb', line 22 def network @network end |
#resource ⇒ Object (readonly, private)
Returns the value of attribute resource.
22 23 24 |
# File 'lib/gitlab/triage/command_builders/base_command_builder.rb', line 22 def resource @resource end |
Instance Method Details
#build_command ⇒ Object
12 13 14 15 16 17 18 |
# File 'lib/gitlab/triage/command_builders/base_command_builder.rb', line 12 def build_command if items.any? [slash_command_string, content_string].compact.join(separator) else "" end end |
#content_string ⇒ Object (private)
32 33 34 35 36 |
# File 'lib/gitlab/triage/command_builders/base_command_builder.rb', line 32 def content_string items.map do |item| format_item(item) end.join(separator) end |
#separator ⇒ Object (private)
24 25 26 |
# File 'lib/gitlab/triage/command_builders/base_command_builder.rb', line 24 def separator ' ' end |
#slash_command_string ⇒ Object (private)
28 29 30 |
# File 'lib/gitlab/triage/command_builders/base_command_builder.rb', line 28 def slash_command_string nil end |