Class: Taskit::Issue

Inherits:
Object
  • Object
show all
Defined in:
lib/taskit/issue.rb

Overview

An issue object, used to normalize the GitHub API response

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(data) ⇒ Issue

Returns a new instance of Issue.



13
14
15
16
17
# File 'lib/taskit/issue.rb', line 13

def initialize(data)
  load_repo_info data
  load_issue_info data
  load_state_info data
end

Instance Attribute Details

#bodyObject (readonly)

Returns the value of attribute body.



9
10
11
# File 'lib/taskit/issue.rb', line 9

def body
  @body
end

#idObject (readonly)

Returns the value of attribute id.



9
10
11
# File 'lib/taskit/issue.rb', line 9

def id
  @id
end

#labelsObject (readonly)

Returns the value of attribute labels.



9
10
11
# File 'lib/taskit/issue.rb', line 9

def labels
  @labels
end

#numberObject (readonly)

Returns the value of attribute number.



9
10
11
# File 'lib/taskit/issue.rb', line 9

def number
  @number
end

#ownerObject (readonly)

Returns the value of attribute owner.



9
10
11
# File 'lib/taskit/issue.rb', line 9

def owner
  @owner
end

#repoObject (readonly)

Returns the value of attribute repo.



9
10
11
# File 'lib/taskit/issue.rb', line 9

def repo
  @repo
end

#repo_urlObject (readonly)

Returns the value of attribute repo_url.



9
10
11
# File 'lib/taskit/issue.rb', line 9

def repo_url
  @repo_url
end

#reporterObject (readonly)

Returns the value of attribute reporter.



9
10
11
# File 'lib/taskit/issue.rb', line 9

def reporter
  @reporter
end

#stateObject (readonly)

Returns the value of attribute state.



9
10
11
# File 'lib/taskit/issue.rb', line 9

def state
  @state
end

#titleObject (readonly)

Returns the value of attribute title.



9
10
11
# File 'lib/taskit/issue.rb', line 9

def title
  @title
end

#urlObject (readonly)

Returns the value of attribute url.



9
10
11
# File 'lib/taskit/issue.rb', line 9

def url
  @url
end

Instance Method Details

#load_issue_info(data) ⇒ Object



26
27
28
29
30
31
# File 'lib/taskit/issue.rb', line 26

def load_issue_info(data)
  @url, @id, @number, @title, @body = data.to_h.values_at(
    :html_url, :id, :number, :title, :body
  )
  @reporter = data[:user][:login]
end

#load_repo_info(data) ⇒ Object



19
20
21
22
23
24
# File 'lib/taskit/issue.rb', line 19

def load_repo_info(data)
  repo_info = data[:repository]
  @repo = repo_info[:name]
  @repo_url = repo_info[:html_url]
  @owner = repo_info[:owner][:login]
end

#load_state_info(data) ⇒ Object



33
34
35
36
# File 'lib/taskit/issue.rb', line 33

def load_state_info(data)
  @state = data[:state]
  @labels = data[:labels].map { |x| Label.new(x[:name], x[:color]) }
end