Class: BlockedStalledChange
- Inherits:
-
Object
- Object
- BlockedStalledChange
- Includes:
- ValueEquality
- Defined in:
- lib/jirametrics/blocked_stalled_change.rb
Instance Attribute Summary collapse
-
#blocking_issue_keys ⇒ Object
readonly
Returns the value of attribute blocking_issue_keys.
-
#flag ⇒ Object
readonly
Returns the value of attribute flag.
-
#flag_reason ⇒ Object
readonly
Returns the value of attribute flag_reason.
-
#stalled_days ⇒ Object
readonly
Returns the value of attribute stalled_days.
-
#status ⇒ Object
readonly
Returns the value of attribute status.
-
#status_is_blocking ⇒ Object
readonly
Returns the value of attribute status_is_blocking.
-
#time ⇒ Object
readonly
Returns the value of attribute time.
Instance Method Summary collapse
- #active? ⇒ Boolean
- #as_symbol ⇒ Object
- #blocked? ⇒ Boolean
- #blocked_by_status? ⇒ Boolean
-
#initialize(time:, flagged: nil, flag_reason: nil, status: nil, status_is_blocking: true, blocking_issue_keys: nil, stalled_days: nil) ⇒ BlockedStalledChange
constructor
A new instance of BlockedStalledChange.
- #inspect ⇒ Object
-
#reasons ⇒ Object
rubocop:disable Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity.
- #stalled? ⇒ Boolean
- #stalled_by_status? ⇒ Boolean
Methods included from ValueEquality
Constructor Details
#initialize(time:, flagged: nil, flag_reason: nil, status: nil, status_is_blocking: true, blocking_issue_keys: nil, stalled_days: nil) ⇒ BlockedStalledChange
Returns a new instance of BlockedStalledChange.
10 11 12 13 14 15 16 17 18 19 |
# File 'lib/jirametrics/blocked_stalled_change.rb', line 10 def initialize time:, flagged: nil, flag_reason: nil, status: nil, status_is_blocking: true, blocking_issue_keys: nil, stalled_days: nil @flag = flagged @flag_reason = flag_reason @status = status @status_is_blocking = status_is_blocking @blocking_issue_keys = blocking_issue_keys @stalled_days = stalled_days @time = time end |
Instance Attribute Details
#blocking_issue_keys ⇒ Object (readonly)
Returns the value of attribute blocking_issue_keys.
8 9 10 |
# File 'lib/jirametrics/blocked_stalled_change.rb', line 8 def blocking_issue_keys @blocking_issue_keys end |
#flag ⇒ Object (readonly)
Returns the value of attribute flag.
8 9 10 |
# File 'lib/jirametrics/blocked_stalled_change.rb', line 8 def flag @flag end |
#flag_reason ⇒ Object (readonly)
Returns the value of attribute flag_reason.
8 9 10 |
# File 'lib/jirametrics/blocked_stalled_change.rb', line 8 def flag_reason @flag_reason end |
#stalled_days ⇒ Object (readonly)
Returns the value of attribute stalled_days.
8 9 10 |
# File 'lib/jirametrics/blocked_stalled_change.rb', line 8 def stalled_days @stalled_days end |
#status ⇒ Object (readonly)
Returns the value of attribute status.
8 9 10 |
# File 'lib/jirametrics/blocked_stalled_change.rb', line 8 def status @status end |
#status_is_blocking ⇒ Object (readonly)
Returns the value of attribute status_is_blocking.
8 9 10 |
# File 'lib/jirametrics/blocked_stalled_change.rb', line 8 def status_is_blocking @status_is_blocking end |
#time ⇒ Object (readonly)
Returns the value of attribute time.
8 9 10 |
# File 'lib/jirametrics/blocked_stalled_change.rb', line 8 def time @time end |
Instance Method Details
#active? ⇒ Boolean
23 |
# File 'lib/jirametrics/blocked_stalled_change.rb', line 23 def active? = !blocked? && !stalled? |
#as_symbol ⇒ Object
45 46 47 48 49 50 51 52 53 |
# File 'lib/jirametrics/blocked_stalled_change.rb', line 45 def as_symbol if blocked? :blocked elsif stalled? :stalled else :active end end |
#blocked? ⇒ Boolean
21 |
# File 'lib/jirametrics/blocked_stalled_change.rb', line 21 def blocked? = !!(@flag || blocked_by_status? || @blocking_issue_keys) |
#blocked_by_status? ⇒ Boolean
25 |
# File 'lib/jirametrics/blocked_stalled_change.rb', line 25 def blocked_by_status? = !!(@status && @status_is_blocking) |
#inspect ⇒ Object
55 56 57 58 59 60 61 62 63 |
# File 'lib/jirametrics/blocked_stalled_change.rb', line 55 def inspect text = "BlockedStalledChange(time: '#{@time}', " if active? text << 'Active' else text << reasons end text << ')' end |
#reasons ⇒ Object
rubocop:disable Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/jirametrics/blocked_stalled_change.rb', line 28 def reasons # rubocop:disable Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity # A flat list of why an item is blocked or stalled: each branch is a single guarded append. # Pulling these apart into helpers would scatter the story across single-use methods without # reading any clearer, so we keep it whole. result = [] if blocked? result << (@flag_reason ? "Blocked by flag: #{@flag_reason}" : 'Blocked by flag') if @flag result << "Blocked by status: #{@status}" if blocked_by_status? result << "Blocked by issues: #{@blocking_issue_keys.join(', ')}" if @blocking_issue_keys elsif stalled_by_status? result << "Stalled by status: #{@status}" elsif @stalled_days result << "Stalled by inactivity: #{@stalled_days} days" end result.join(', ') end |
#stalled? ⇒ Boolean
22 |
# File 'lib/jirametrics/blocked_stalled_change.rb', line 22 def stalled? = !!(@stalled_days || stalled_by_status?) |
#stalled_by_status? ⇒ Boolean
26 |
# File 'lib/jirametrics/blocked_stalled_change.rb', line 26 def stalled_by_status? = !!(@status && !@status_is_blocking) |