Sha256: afe170228ff19e64902f9693b7a4345cfaa8cb6c56e4c60900952f9416b8d852
Contents?: true
Size: 984 Bytes
Versions: 3
Compression:
Stored size: 984 Bytes
Contents
# 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) <a href="#{CGI.escapeHTML(href.raw.to_s)}">#{CGI.escapeHTML(text.raw.to_s)}</a> LINK end def self.code_escape(string = nil) string ||= Nothing.new String.new(CGI.escapeHTML(string.raw.to_s)) end end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
code-ruby-1.1.3 | lib/code/object/html.rb |
code-ruby-1.1.1 | lib/code/object/html.rb |
code-ruby-1.1.0 | lib/code/object/html.rb |