Class: Status

Inherits:
Object show all
Includes:
ValueEquality
Defined in:
lib/jirametrics/status.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from ValueEquality

#==, #eql?

Constructor Details

#initialize(name: nil, id: nil, category_name: nil, category_id: nil, project_id: nil, raw: nil) ⇒ Status

Returns a new instance of Status.



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/jirametrics/status.rb', line 10

def initialize name: nil, id: nil, category_name: nil, category_id: nil, project_id: nil, raw: nil
  @name = name
  @id = id
  @category_name = category_name
  @category_id = category_id
  @project_id = project_id

  return unless raw

  @raw = raw
  @name = raw['name']
  @id = raw['id'].to_i

  category_config = raw['statusCategory']
  @category_name = category_config['name']
  @category_id = category_config['id'].to_i

  # If this is a NextGen project then this status may be project specific. When this field is
  # nil then the status is global.
  @project_id = raw['scope']&.[]('project')&.[]('id')
end

Instance Attribute Details

#category_idObject (readonly)

Returns the value of attribute category_id.



7
8
9
# File 'lib/jirametrics/status.rb', line 7

def category_id
  @category_id
end

#category_nameObject (readonly)

Returns the value of attribute category_name.



7
8
9
# File 'lib/jirametrics/status.rb', line 7

def category_name
  @category_name
end

#idObject (readonly)

Returns the value of attribute id.



7
8
9
# File 'lib/jirametrics/status.rb', line 7

def id
  @id
end

#nameObject

Returns the value of attribute name.



8
9
10
# File 'lib/jirametrics/status.rb', line 8

def name
  @name
end

#project_idObject (readonly)

Returns the value of attribute project_id.



7
8
9
# File 'lib/jirametrics/status.rb', line 7

def project_id
  @project_id
end

Instance Method Details

#global?Boolean

Returns:

  • (Boolean)


36
37
38
# File 'lib/jirametrics/status.rb', line 36

def global?
  !project_scoped?
end

#project_scoped?Boolean

Returns:

  • (Boolean)


32
33
34
# File 'lib/jirametrics/status.rb', line 32

def project_scoped?
  !!@project_id
end

#to_sObject



40
41
42
43
# File 'lib/jirametrics/status.rb', line 40

def to_s
  "Status(name=#{@name.inspect}, id=#{@id.inspect}," \
    " category_name=#{@category_name.inspect}, category_id=#{@category_id.inspect}, project_id=#{@project_id})"
end

#value_equality_ignored_variablesObject



45
46
47
# File 'lib/jirametrics/status.rb', line 45

def value_equality_ignored_variables
  [:@raw]
end