Class: Delivery::PrintLabels::Result

Inherits:
Data
  • Object
show all
Defined in:
app/services/delivery/print_labels.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#job_idsArray<String> (readonly)

Returns PrintNode job ids; empty unless a profile printed.

Returns:

  • (Array<String>)

    PrintNode job ids; empty unless a profile printed



33
34
35
36
37
38
39
40
41
42
43
44
45
# File 'app/services/delivery/print_labels.rb', line 33

Result = Data.define(:uploads, :print_profile, :job_ids) do
  # @return [Boolean] whether the documents actually reached a printer
  def printed?
    print_profile.present? && job_ids.any?
  end

  # @return [String, nil] operator-facing confirmation, nil when nothing printed
  def message
    return unless printed?

    "Submitted ship labels upload to print profile #{print_profile.name} [#{print_profile.id}], job #{job_ids.join(', ')}"
  end
end

Returns nil when no profile was selected or the
selected one no longer exists.

Returns:

  • (PrintProfile, nil)

    nil when no profile was selected or the
    selected one no longer exists



33
34
35
36
37
38
39
40
41
42
43
44
45
# File 'app/services/delivery/print_labels.rb', line 33

Result = Data.define(:uploads, :print_profile, :job_ids) do
  # @return [Boolean] whether the documents actually reached a printer
  def printed?
    print_profile.present? && job_ids.any?
  end

  # @return [String, nil] operator-facing confirmation, nil when nothing printed
  def message
    return unless printed?

    "Submitted ship labels upload to print profile #{print_profile.name} [#{print_profile.id}], job #{job_ids.join(', ')}"
  end
end

#uploadsArray<Upload> (readonly)

Returns every document assembled for this print run,
whether or not it was piped to a printer.

Returns:

  • (Array<Upload>)

    every document assembled for this print run,
    whether or not it was piped to a printer



33
34
35
36
37
38
39
40
41
42
43
44
45
# File 'app/services/delivery/print_labels.rb', line 33

Result = Data.define(:uploads, :print_profile, :job_ids) do
  # @return [Boolean] whether the documents actually reached a printer
  def printed?
    print_profile.present? && job_ids.any?
  end

  # @return [String, nil] operator-facing confirmation, nil when nothing printed
  def message
    return unless printed?

    "Submitted ship labels upload to print profile #{print_profile.name} [#{print_profile.id}], job #{job_ids.join(', ')}"
  end
end

Instance Method Details

#messageString?

Returns operator-facing confirmation, nil when nothing printed.

Returns:

  • (String, nil)

    operator-facing confirmation, nil when nothing printed



40
41
42
43
44
# File 'app/services/delivery/print_labels.rb', line 40

def message
  return unless printed?

  "Submitted ship labels upload to print profile #{print_profile.name} [#{print_profile.id}], job #{job_ids.join(', ')}"
end

#printed?Boolean

Returns whether the documents actually reached a printer.

Returns:

  • (Boolean)

    whether the documents actually reached a printer



35
36
37
# File 'app/services/delivery/print_labels.rb', line 35

def printed?
  print_profile.present? && job_ids.any?
end