class Pug::Types::Result

Encapsulates a sucess/failure result @!attribute type

@return [Integer] the type of the Result
@see Result::SUCCESS
@see Result::INFO
@see Result::ERROR

@!attribute value

@return [String] the value of the Result
@note exists only for SUCCESS and INFO types

@!attribute error

@return [String] the output of the Action
@note exists only for ERROR type

Constants

ERROR
INFO
SUCCESS

@!group Types

Attributes

error[R]
type[R]
value[R]

Public Class Methods

error(error) click to toggle source

Defines an ERROR Result @param error [String] error for Result @return [Result] with error and no value

# File lib/pug/types/result.rb, line 52
def self.error(error)
  new(ERROR, nil, error)
end
info(value) click to toggle source

Defines an INFO Result @param value [String] value for Result @return [Result] with value and no error

# File lib/pug/types/result.rb, line 45
def self.info(value)
  new(INFO, value, nil)
end
new(type, value, error) click to toggle source

@!visibility private

# File lib/pug/types/result.rb, line 28
def initialize(type, value, error)
  raise 'Invalid type' unless [SUCCESS, INFO, ERROR].include?(type)
  @type = type
  @value = value
  @error = error
end
success(value) click to toggle source

Defines a SUCCESS Result @param value [String] value for Result @return [Result] with value and no error

# File lib/pug/types/result.rb, line 38
def self.success(value)
  new(SUCCESS, value, nil)
end