1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39
|
# frozen_string_literal: true
require_relative "necromancer/context"
require_relative "necromancer/version"
module Necromancer
# Raised when cannot conver to a given type
ConversionTypeError = Class.new(StandardError)
# Raised when conversion type is not available
NoTypeConversionAvailableError = Class.new(StandardError)
# Create a conversion instance
#
# @example
# converter = Necromancer.new
#
# @return [Context]
#
# @api private
def new(&block)
Context.new(&block)
end
module_function :new
# Convenience to directly call conversion
#
# @example
# Necromancer.convert("1").to(:integer)
# # => 1
#
# @return [ConversionTarget]
#
# @api public
def convert(*args, &block)
Context.new.convert(*args, &block)
end
module_function :convert
end # Necromancer
|