Class: Code::Object::Html
Constant Summary
Constants inherited
from Code::Object
NUMBER_CLASSES
Instance Attribute Summary
Attributes inherited from Code::Object
#raw
Class Method Summary
collapse
#<=>, #==, #as_json, as_json, #call, code_and_operator, #code_and_operator, #code_as_json, code_as_json, code_different, #code_different, code_equal_equal, #code_equal_equal, code_equal_equal_equal, #code_equal_equal_equal, code_exclamation_point, #code_exclamation_point, code_exclusive_range, #code_exclusive_range, code_inclusive_range, #code_inclusive_range, code_new, code_or_operator, #code_or_operator, #code_self, code_self, #code_to_json, code_to_json, falsy?, #falsy?, #hash, #initialize, inspect, maybe, #multi_fetch, multi_fetch, nothing?, #nothing?, repeat, sig, #sig, #succ, #to_code, to_json, #to_json, to_s, truthy?, #truthy?, |
Constructor Details
This class inherits a constructor from Code::Object
Class Method Details
.call(**args) ⇒ Object
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
|
# File 'lib/code/object/html.rb', line 6
def self.call(**args)
code_operator = args.fetch(:operator, nil).to_code
code_arguments = args.fetch(:arguments, []).to_code
case code_operator.to_s
when "link_to"
sig(args) { [Object.maybe, Object.maybe] }
code_link_to(*code_arguments.raw)
when "escape"
sig(args) { Object.maybe }
code_escape(*code_arguments.raw)
else
super
end
end
|
.code_escape(string = nil) ⇒ Object
33
34
35
36
37
|
# File 'lib/code/object/html.rb', line 33
def self.code_escape(string = nil)
code_string = string.to_code
String.new(CGI.escapeHTML(string.to_s))
end
|
.code_link_to(text = nil, href = nil) ⇒ Object
22
23
24
25
26
27
28
29
30
31
|
# File 'lib/code/object/html.rb', line 22
def self.code_link_to(text = nil, href = nil)
code_text = text.to_code
code_href = href.to_code
String.new(" <a\n href=\"\#{CGI.escapeHTML(code_href.to_s)}\"\n >\#{CGI.escapeHTML(code_text.to_s)}</a>\n LINK\nend\n".strip)
|