Class: Geet::Github::Milestone

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

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(number, title, due_on, api_interface) ⇒ Milestone

Returns a new instance of Milestone.



10
11
12
13
14
15
16
# File 'lib/geet/github/milestone.rb', line 10

def initialize(number, title, due_on, api_interface)
  @number = number
  @title = title
  @due_on = due_on

  @api_interface = api_interface
end

Instance Attribute Details

#due_onObject (readonly)

Returns the value of attribute due_on.



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

def due_on
  @due_on
end

#numberObject (readonly)

Returns the value of attribute number.



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

def number
  @number
end

#titleObject (readonly)

Returns the value of attribute title.



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

def title
  @title
end

Class Method Details

.find(number, api_interface) ⇒ Object



20
21
22
23
24
25
26
27
28
29
30
# File 'lib/geet/github/milestone.rb', line 20

def self.find(number, api_interface)
  api_path = "milestones/#{number}"

  response = api_interface.send_request(api_path)

  number = response.fetch('number')
  title = response.fetch('title')
  due_on = parse_due_on(response.fetch('due_on'))

  new(number, title, due_on, api_interface)
end

.list(api_interface) ⇒ Object



34
35
36
37
38
39
40
41
42
43
44
45
46
# File 'lib/geet/github/milestone.rb', line 34

def self.list(api_interface)
  api_path = 'milestones'

  response = api_interface.send_request(api_path, multipage: true)

  response.map do |milestone_data|
    number = milestone_data.fetch('number')
    title = milestone_data.fetch('title')
    due_on = parse_due_on(milestone_data.fetch('due_on'))

    new(number, title, due_on, api_interface)
  end
end