Class: Slk::Models::StatusSnapshot

Inherits:
Data
  • Object
show all
Defined in:
lib/slk/models/status_snapshot.rb

Overview

Everything slk status knows about one workspace at one moment: the status itself, plus the two things that decide whether anyone can reach you (presence, DND) and whatever is queued to replace the status later.

Every part but the status is optional, and nil means "not checked" — skipped by a flag, or a lookup that failed. That is deliberately distinct from checked-and-empty: scheduled: [] says nothing is queued, while scheduled: nil says nobody looked.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(workspace:, status:, presence: nil, dnd: nil, scheduled: nil) ⇒ StatusSnapshot

Returns a new instance of StatusSnapshot.



14
15
16
# File 'lib/slk/models/status_snapshot.rb', line 14

def initialize(workspace:, status:, presence: nil, dnd: nil, scheduled: nil)
  super
end

Instance Attribute Details

#dndObject (readonly)

Returns the value of attribute dnd

Returns:

  • (Object)

    the current value of dnd



13
14
15
# File 'lib/slk/models/status_snapshot.rb', line 13

def dnd
  @dnd
end

#presenceObject (readonly)

Returns the value of attribute presence

Returns:

  • (Object)

    the current value of presence



13
14
15
# File 'lib/slk/models/status_snapshot.rb', line 13

def presence
  @presence
end

#scheduledObject (readonly)

Returns the value of attribute scheduled

Returns:

  • (Object)

    the current value of scheduled



13
14
15
# File 'lib/slk/models/status_snapshot.rb', line 13

def scheduled
  @scheduled
end

#statusObject (readonly)

Returns the value of attribute status

Returns:

  • (Object)

    the current value of status



13
14
15
# File 'lib/slk/models/status_snapshot.rb', line 13

def status
  @status
end

#workspaceObject (readonly)

Returns the value of attribute workspace

Returns:

  • (Object)

    the current value of workspace



13
14
15
# File 'lib/slk/models/status_snapshot.rb', line 13

def workspace
  @workspace
end

Instance Method Details

#away?Boolean

Returns:

  • (Boolean)


20
# File 'lib/slk/models/status_snapshot.rb', line 20

def away? = presence ? presence[:presence] == 'away' : false

#labelsObject

Short suffixes for the status line. Only the exceptional states appear: active presence and DND-off are the common case, and repeating them on every line would bury the workspace that differs.



25
26
27
# File 'lib/slk/models/status_snapshot.rb', line 25

def labels
  [('[away]' if away?), dnd&.to_s].reject { |label| label.to_s.empty? }
end

#workspace_nameObject



18
# File 'lib/slk/models/status_snapshot.rb', line 18

def workspace_name = workspace.name