Sha256: d49fe9c5574bbf33db6c16469b2210252f6d88b70c50392867e063c5bdbeab17
Contents?: true
Size: 891 Bytes
Versions: 2
Compression:
Stored size: 891 Bytes
Contents
class Jcompiler::Provider def initialize @context = nil end def object!(arg_name = nil, &block) pre_context = @context @context = [] srcs, subst_src = if arg_name [block.call(nil), "#{block.parameters[0][1]}=#{arg_name};"] else [block.call, ''] end @context = pre_context %{"{\#{#{subst_src}[#{srcs.join(',')}].join(',')}}"} end def array!(arg_name, &block) item_name = block.parameters[0][1].to_s src = block.call(nil) %{"[\#{#{arg_name}.map { |#{item_name}| #{src} }.join(',')}]"} end def number!(num) %{"#{num}"} end def method_missing(name, *args, &block) src = if block block.call else args[0] end @context << %{"\\"#{name}\\":\#{#{src}}"} end protected def value! end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
jcompiler-0.1.115 | lib/jcompiler/provider.rb |
jcompiler-0.1.114 | lib/jcompiler/provider.rb |