Class: Dhall::AsDhall::ExpressionList::Optional

Inherits:
Object
  • Object
show all
Defined in:
lib/dhall/as_dhall.rb

Instance Method Summary collapse

Constructor Details

#initialize(_, exprs, types) ⇒ Optional

Returns a new instance of Optional.



170
171
172
173
# File 'lib/dhall/as_dhall.rb', line 170

def initialize(_, exprs, types)
	@type = types.compact.first
	@exprs = exprs
end

Instance Method Details

#listObject



175
176
177
178
179
180
181
182
183
# File 'lib/dhall/as_dhall.rb', line 175

def list
	List.new(elements: @exprs.map do |x|
		if x.nil?
			Dhall::OptionalNone.new(value_type: @type)
		else
			Dhall::Optional.new(value: x)
		end
	end)
end