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.



10
11
12
13
# File 'lib/geet/github/label.rb', line 10

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

Instance Attribute Details

#colorObject (readonly)

Returns the value of attribute color.



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

def color
  @color
end

#nameObject (readonly)

Returns the value of attribute name.



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

def name
  @name
end

Class Method Details

.create(name, color, api_interface) ⇒ Object



29
30
31
32
33
34
35
36
# File 'lib/geet/github/label.rb', line 29

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.



16
17
18
19
20
21
22
23
24
25
26
# File 'lib/geet/github/label.rb', line 16

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