Sha256: ac44f6b4408300fec2bcbc5bb13074a0d80dbbf0f3adf775d20d62e1bb4439d5

Contents?: true

Size: 659 Bytes

Versions: 1

Compression:

Stored size: 659 Bytes

Contents

# frozen_string_literal: true

module Neco
  # Base class of Result
  class Result
  end

  # Success is returned when the command executed successfully.
  class Success < Result
    def success?
      true
    end

    def failure?
      false
    end
  end

  # Failure is returned when the command failed.
  # This class has several extra information because failure has many ways to achieve
  # while success has only one way.
  class Failure < Result
    def initialize(exception:)
      @exception = exception
    end

    def success?
      false
    end

    def failure?
      true
    end

    def message
      @exception.message
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
neco-0.2.0 lib/neco/result.rb