Class: Code::Object::Global
- Inherits:
-
Code::Object
- Object
- Code::Object
- Code::Object::Global
- Defined in:
- lib/code/object/global.rb
Constant Summary
Constants inherited from Code::Object
Instance Attribute Summary
Attributes included from Concerns::Shared
Instance Method Summary collapse
Methods inherited from Code::Object
code_new, #code_new, #initialize, maybe, #name, repeat, |
Methods included from Concerns::Shared
#<=>, #==, #as_json, #code_and, #code_as_json, #code_compare, #code_deep_duplicate, #code_different, #code_duplicate, #code_equal, #code_exclamation_mark, #code_exclusive_range, #code_falsy?, code_fetch, #code_fetch, code_get, #code_get, #code_greater, #code_greater_or_equal, #code_inclusive_range, #code_inspect, #code_less, #code_less_or_equal, #code_methods, #code_name, #code_nothing?, #code_or, #code_self, #code_set, code_set, #code_something?, #code_strict_different, #code_strict_equal, #code_to_boolean, #code_to_class, #code_to_date, #code_to_decimal, #code_to_dictionary, #code_to_duration, #code_to_integer, #code_to_json, #code_to_list, #code_to_nothing, #code_to_parameter, #code_to_range, #code_to_string, #code_to_time, #code_truthy?, #eql?, #falsy?, #hash, #inspect, #multi_fetch, #nothing?, #sig, #something?, #succ, #to_code, #to_i, #to_json, #to_s, #truthy?
Constructor Details
This class inherits a constructor from Code::Object
Instance Method Details
#call(**args) ⇒ Object
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 |
# File 'lib/code/object/global.rb', line 6 def call(**args) code_operator = args.fetch(:operator, nil).to_code code_arguments = args.fetch(:arguments, []).to_code output = args.fetch(:output) input = args.fetch(:input) code_context = args.fetch(:context).to_code code_value = code_arguments.code_first globals = multi_fetch(args, *GLOBALS) case code_operator.to_s when "Boolean" sig(args) { Object.repeat } if code_arguments.any? Boolean.new(*code_arguments.raw) else Class.new(Boolean) end when "break" sig(args) { Object.repeat } raise Error::Break, code_value || Nothing.new when "next" sig(args) { Object.repeat } raise Error::Next, code_value || Nothing.new when "Class" sig(args) { Object.repeat } if code_arguments.any? Class.new(*code_arguments.raw) else Class.new(Class) end when "Date" sig(args) { Object.repeat } code_arguments.any? ? Date.new(*code_arguments.raw) : Class.new(Date) when "Decimal" sig(args) { Object.repeat } if code_arguments.any? Decimal.new(*code_arguments.raw) else Class.new(Decimal) end when "Dictionary" sig(args) { Object.repeat } if code_arguments.any? Dictionary.new(*code_arguments.raw) else Class.new(Dictionary) end when "Duration" sig(args) { Object.repeat } if code_arguments.any? Duration.new(*code_arguments.raw) else Class.new(Duration) end when "Function" sig(args) if code_arguments.any? Function.new(*code_arguments.raw) else Class.new(Function) end when "Integer" sig(args) { Object.repeat } if code_arguments.any? Integer.new(*code_arguments.raw) else Class.new(Integer) end when "List" sig(args) { Object.repeat } code_arguments.any? ? List.new(*code_arguments.raw) : Class.new(List) when "Nothing" sig(args) { Object.repeat } if code_arguments.any? Nothing.new(*code_arguments.raw) else Class.new(Nothing) end when "context" sig(args) code_context when "Object" sig(args) if code_arguments.any? Object.new(*code_arguments.raw) else Class.new(Object) end when "Range" sig(args) { Object.repeat } if code_arguments.any? Range.new(*code_arguments.raw) else Class.new(Range) end when "String" sig(args) { Object.repeat } if code_arguments.any? String.new(*code_arguments.raw) else Class.new(String) end when "Time" sig(args) { Object.repeat } code_arguments.any? ? Time.new(*code_arguments.raw) : Class.new(Time) when "Context" sig(args) { Object.repeat } if code_arguments.any? Context.new(*code_arguments.raw) else Class.new(Context) end when "Code" sig(args) { Object.repeat } code_arguments.any? ? Code.new(*code_arguments.raw) : Class.new(Code) when "Parameter" sig(args) { Object.repeat } if code_arguments.any? Parameter.new(*code_arguments.raw) else Class.new(Parameter) end when "IdentifierList" sig(args) { Object.repeat } if code_arguments.any? IdentifierList.new(*code_arguments.raw) else Class.new(IdentifierList) end when "Html" sig(args) { Object.repeat } code_arguments.any? ? Html.new(*code_arguments.raw) : Class.new(Html) when "Http" sig(args) { Object.repeat } code_arguments.any? ? Http.new(*code_arguments.raw) : Class.new(Http) when "Smtp" sig(args) { Object.repeat } code_arguments.any? ? Smtp.new(*code_arguments.raw) : Class.new(Smtp) when "Base64" sig(args) { Object.repeat } if code_arguments.any? Base64.new(*code_arguments.raw) else Class.new(Base64) end when "Json" sig(args) { Object.repeat } code_arguments.any? ? Json.new(*code_arguments.raw) : Class.new(Json) when "evaluate" sig(args) { Object } Code.code_evaluate(code_value.code_to_string, **globals) when "p" sig(args) { Object.repeat } output.puts(*code_arguments.raw.map(&:inspect)) Nothing.new when "print" sig(args) { Object.repeat } output.print(*code_arguments.raw) Nothing.new when "read" sig(args) { Object.repeat } input.gets.to_code when "puts" sig(args) { Object.repeat } output.puts(*code_arguments.raw) Nothing.new when "Number" sig(args) { Object.repeat } if code_arguments.any? Number.new(*code_arguments.raw) else Class.new(Number) end else code_context = code_context.code_lookup!(code_operator) code_result = code_context.code_fetch(code_operator) if code_result.is_a?(Function) code_result.call(**args, operator: nil) else sig(args) code_result end end end |