Class: Geet::Github::Label

Inherits:
Object
  • Object
show all
Defined in:
lib/geet/github/label.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, color) ⇒ Label

Returns a new instance of Label.



8
9
10
11
# File 'lib/geet/github/label.rb', line 8

def initialize(name, color)
  @name = name
  @color = color
end

Instance Attribute Details

#colorObject (readonly)

Returns the value of attribute color.



6
7
8
# File 'lib/geet/github/label.rb', line 6

def color
  @color
end

#nameObject (readonly)

Returns the value of attribute name.



6
7
8
# File 'lib/geet/github/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/github/label.rb', line 27

def self.create(name, color, api_interface, **)
  api_path = '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/github/label.rb', line 14

def self.list(api_interface, **)
  api_path = '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')

    new(name, color)
  end
end