Class: Geet::Gitlab::Label
- Inherits:
-
Object
- Object
- Geet::Gitlab::Label
- Defined in:
- lib/geet/gitlab/label.rb
Instance Attribute Summary collapse
-
#color ⇒ Object
readonly
Returns the value of attribute color.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Class Method Summary collapse
- .create(name, color, api_interface) ⇒ Object
-
.list(api_interface) ⇒ Object
Returns a flat list of names in string form.
Instance Method Summary collapse
-
#initialize(name, color) ⇒ Label
constructor
A new instance of Label.
Constructor Details
#initialize(name, color) ⇒ Label
Returns a new instance of Label.
8 9 10 11 |
# File 'lib/geet/gitlab/label.rb', line 8 def initialize(name, color) @name = name @color = color end |
Instance Attribute Details
#color ⇒ Object (readonly)
Returns the value of attribute color.
6 7 8 |
# File 'lib/geet/gitlab/label.rb', line 6 def color @color end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
6 7 8 |
# File 'lib/geet/gitlab/label.rb', line 6 def name @name end |
Class Method Details
.create(name, color, api_interface) ⇒ Object
27 28 29 30 31 32 33 34 |
# File 'lib/geet/gitlab/label.rb', line 27 def self.create(name, color, api_interface, **) api_path = "projects/#{api_interface.path_with_namespace(encoded: true)}/labels" request_data = { name: name, color: "##{color}" } api_interface.send_request(api_path, data: request_data) new(name, color) end |
.list(api_interface) ⇒ Object
Returns a flat list of names in string form.
14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/geet/gitlab/label.rb', line 14 def self.list(api_interface, **) api_path = "projects/#{api_interface.path_with_namespace(encoded: true)}/labels" response = api_interface.send_request(api_path, multipage: true) response.map do |label_entry| name = label_entry.fetch('name') color = label_entry.fetch('color').sub('#', '') # normalize new(name, color) end end |