Class: Status
- Inherits:
-
Object
- Object
- Status
- Defined in:
- lib/jirametrics/status.rb
Defined Under Namespace
Classes: Category
Instance Attribute Summary collapse
-
#category ⇒ Object
readonly
Returns the value of attribute category.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#name ⇒ Object
Returns the value of attribute name.
-
#project_id ⇒ Object
readonly
Returns the value of attribute project_id.
Class Method Summary collapse
Instance Method Summary collapse
- #<=>(other) ⇒ Object
- #==(other) ⇒ Object
- #artificial? ⇒ Boolean
- #eql?(other) ⇒ Boolean
- #global? ⇒ Boolean
-
#initialize(name:, id:, category_name:, category_id:, category_key:, project_id: nil, artificial: true) ⇒ Status
constructor
A new instance of Status.
- #inspect ⇒ Object
- #project_scoped? ⇒ Boolean
- #to_s ⇒ Object
- #value_equality_ignored_variables ⇒ Object
Constructor Details
#initialize(name:, id:, category_name:, category_id:, category_key:, project_id: nil, artificial: true) ⇒ Status
Returns a new instance of Status.
55 56 57 58 59 60 61 62 63 64 65 |
# File 'lib/jirametrics/status.rb', line 55 def initialize name:, id:, category_name:, category_id:, category_key:, project_id: nil, artificial: true # These checks are needed because nils used to be possible and now they aren't. raise 'id cannot be nil' if id.nil? raise 'category_id cannot be nil' if category_id.nil? @name = name @id = id @category = Category.new id: category_id, name: category_name, key: category_key @project_id = project_id @artificial = artificial end |
Instance Attribute Details
#category ⇒ Object (readonly)
Returns the value of attribute category.
6 7 8 |
# File 'lib/jirametrics/status.rb', line 6 def category @category end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
6 7 8 |
# File 'lib/jirametrics/status.rb', line 6 def id @id end |
#name ⇒ Object
Returns the value of attribute name.
7 8 9 |
# File 'lib/jirametrics/status.rb', line 7 def name @name end |
#project_id ⇒ Object (readonly)
Returns the value of attribute project_id.
6 7 8 |
# File 'lib/jirametrics/status.rb', line 6 def project_id @project_id end |
Class Method Details
.from_raw(raw) ⇒ Object
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/jirametrics/status.rb', line 38 def self.from_raw raw raise "raw cannot be nil" if raw.nil? category_config = raw['statusCategory'] raise "statusCategory can't be nil in #{category_config.inspect}" if category_config.nil? Status.new( name: raw['name'], id: raw['id'].to_i, category_name: category_config['name'], category_id: category_config['id'].to_i, category_key: category_config['key'], project_id: raw['scope']&.[]('project')&.[]('id'), artificial: false ) end |
Instance Method Details
#<=>(other) ⇒ Object
93 94 95 96 97 |
# File 'lib/jirametrics/status.rb', line 93 def <=> other result = @name.casecmp(other.name) result = @id <=> other.id if result.zero? result end |
#==(other) ⇒ Object
83 84 85 86 87 |
# File 'lib/jirametrics/status.rb', line 83 def == other return false unless other.is_a? Status @id == other.id && @name == other.name && @category.id == other.category.id && @category.name == other.category.name end |
#artificial? ⇒ Boolean
79 80 81 |
# File 'lib/jirametrics/status.rb', line 79 def artificial? @artificial end |
#eql?(other) ⇒ Boolean
89 90 91 |
# File 'lib/jirametrics/status.rb', line 89 def eql?(other) self == other end |
#global? ⇒ Boolean
71 72 73 |
# File 'lib/jirametrics/status.rb', line 71 def global? !project_scoped? end |
#inspect ⇒ Object
99 100 101 102 103 104 105 106 107 108 |
# File 'lib/jirametrics/status.rb', line 99 def inspect result = [] result << "Status(name: #{@name.inspect}" result << "id: #{@id.inspect}" result << "project_id: #{@project_id}" if @project_id category = self.category result << "category: {name:#{category.name.inspect}, id: #{category.id.inspect}, key: #{category.key.inspect}}" result << 'artificial' if artificial? result.join(', ') << ')' end |
#project_scoped? ⇒ Boolean
67 68 69 |
# File 'lib/jirametrics/status.rb', line 67 def project_scoped? !!@project_id end |
#to_s ⇒ Object
75 76 77 |
# File 'lib/jirametrics/status.rb', line 75 def to_s "#{name.inspect}:#{id.inspect}" end |
#value_equality_ignored_variables ⇒ Object
110 111 112 |
# File 'lib/jirametrics/status.rb', line 110 def value_equality_ignored_variables [:@raw] end |