module WAG::Encodable
A simple mixin which formats s-expressions as WAT
.
Public Instance Methods
to_wasm()
click to toggle source
# File lib/wag/encodable.rb, line 10 def to_wasm to_wat.to_wasm end
to_wat()
click to toggle source
# File lib/wag/encodable.rb, line 6 def to_wat WAG::WAT.new(wat_encode(to_sexpr)) end
Private Instance Methods
wat_encode(data)
click to toggle source
# File lib/wag/encodable.rb, line 16 def wat_encode(data) return "(#{data.map { |e| wat_encode(e) }.join(' ')})" if data.is_a?(Enumerable) return data.inspect if data.is_a?(String) data.to_s end