Class: Geet::Github::Milestone

Inherits:
Object
  • Object
show all
Extended by:
Helpers::JsonHelper
Defined in:
lib/geet/github/milestone.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Helpers::JsonHelper

parse_iso_8601_timestamp

Constructor Details

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

Returns a new instance of Milestone.



16
17
18
19
20
21
22
# File 'lib/geet/github/milestone.rb', line 16

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



26
27
28
29
30
31
32
33
34
35
36
# File 'lib/geet/github/milestone.rb', line 26

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_iso_8601_timestamp(raw_due_on)

  new(number, title, due_on, api_interface)
end

.list(api_interface) ⇒ Object



40
41
42
43
44
45
46
47
48
49
50
51
52
# File 'lib/geet/github/milestone.rb', line 40

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_iso_8601_timestamp(milestone_data.fetch('due_on'))

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