# frozen_string_literal: true class Code class Object class Html < Object def initialize(*_args, **_kargs, &) @raw = nil end def self.call(**args) operator = args.fetch(:operator, nil) arguments = args.fetch(:arguments, List.new) case operator.to_s when "link_to" sig(args) { [Object.maybe, Object.maybe] } code_link_to(*arguments.raw) when "escape" sig(args) { Object.maybe } code_escape(*arguments.raw) else super end end def self.code_link_to(text = nil, href = nil) text ||= Nothing.new href ||= Nothing.new String.new(<<~LINK.strip) #{CGI.escapeHTML(text.raw.to_s)} LINK end def self.code_escape(string = nil) string ||= Nothing.new String.new(CGI.escapeHTML(string.raw.to_s)) end end end end