Class: Soba::Domain::Issue

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attributes = {}) ⇒ Issue

Returns a new instance of Issue.



8
9
10
11
12
13
14
15
16
17
# File 'lib/soba/domain/issue.rb', line 8

def initialize(attributes = {})
  @id = attributes[:id]
  @number = attributes[:number]
  @title = attributes[:title]
  @body = attributes[:body]
  @state = attributes[:state]
  @labels = attributes[:labels] || []
  @created_at = attributes[:created_at]
  @updated_at = attributes[:updated_at]
end

Instance Attribute Details

#bodyObject (readonly)

Returns the value of attribute body.



6
7
8
# File 'lib/soba/domain/issue.rb', line 6

def body
  @body
end

#created_atObject (readonly)

Returns the value of attribute created_at.



6
7
8
# File 'lib/soba/domain/issue.rb', line 6

def created_at
  @created_at
end

#idObject (readonly)

Returns the value of attribute id.



6
7
8
# File 'lib/soba/domain/issue.rb', line 6

def id
  @id
end

#labelsObject (readonly)

Returns the value of attribute labels.



6
7
8
# File 'lib/soba/domain/issue.rb', line 6

def labels
  @labels
end

#numberObject (readonly)

Returns the value of attribute number.



6
7
8
# File 'lib/soba/domain/issue.rb', line 6

def number
  @number
end

#stateObject (readonly)

Returns the value of attribute state.



6
7
8
# File 'lib/soba/domain/issue.rb', line 6

def state
  @state
end

#titleObject (readonly)

Returns the value of attribute title.



6
7
8
# File 'lib/soba/domain/issue.rb', line 6

def title
  @title
end

#updated_atObject (readonly)

Returns the value of attribute updated_at.



6
7
8
# File 'lib/soba/domain/issue.rb', line 6

def updated_at
  @updated_at
end

Instance Method Details

#closed?Boolean

Returns:



23
24
25
# File 'lib/soba/domain/issue.rb', line 23

def closed?
  state == "closed"
end

#has_label?(label_name) ⇒ Boolean

Returns:



27
28
29
# File 'lib/soba/domain/issue.rb', line 27

def has_label?(label_name)
  labels.any? { |label| label[:name] == label_name }
end

#open?Boolean

Returns:



19
20
21
# File 'lib/soba/domain/issue.rb', line 19

def open?
  state == "open"
end

#priorityObject



31
32
33
34
35
# File 'lib/soba/domain/issue.rb', line 31

def priority
  return :high if has_label?("critical") || has_label?("urgent")
  return :medium if has_label?("important")
  :low
end