Class: Literal::SuccessType

Inherits:
Generic
  • Object
show all
Defined in:
lib/literal/success_type.rb

Instance Method Summary collapse

Methods included from Modifiers

extended

Constructor Details

#initialize(type) ⇒ SuccessType

Returns a new instance of SuccessType.



4
5
6
# File 'lib/literal/success_type.rb', line 4

def initialize(type)
	@type = type
end

Instance Method Details

#===(value) ⇒ Object



10
11
12
# File 'lib/literal/success_type.rb', line 10

def ===(value)
	Literal::Success === value && @type === value.value
end

#inspectObject



8
# File 'lib/literal/success_type.rb', line 8

def inspect = "Literal::Success(#{@type.inspect})"

#new(value) ⇒ Object



14
15
16
17
18
19
20
# File 'lib/literal/success_type.rb', line 14

def new(value)
	if @type === value
		Literal::Success.new(value)
	else
		raise Literal::TypeError.expected(value, to_be_a: @type)
	end
end