Class: Code::Object::Context
- Inherits:
-
Dictionary
- Object
- Code::Object
- Dictionary
- Code::Object::Context
- Defined in:
- lib/code/object/context.rb
Constant Summary
Constants inherited from Code::Object
Instance Attribute Summary collapse
-
#parent ⇒ Object
readonly
Returns the value of attribute parent.
Attributes inherited from Code::Object
Instance Method Summary collapse
- #code_lookup!(identifier) ⇒ Object
-
#initialize(*args, **_kargs) ⇒ Context
constructor
A new instance of Context.
- #merge(other) ⇒ Object
- #parent? ⇒ Boolean
Methods inherited from Dictionary
#call, #code_any?, #code_clear, #code_compact, #code_compact!, #code_compare, #code_delete, #code_delete_if, #code_delete_unless, #code_dig, #code_each, #code_empty?, #code_except, #code_fetch, #code_fetch_values, #code_flatten, #code_get, #code_has_key?, #code_has_value?, #code_inferior, #code_inferior_or_equal, #code_invert, #code_keep_if, #code_keep_unless, #code_key, #code_keys, #code_merge, #code_merge!, #code_select, #code_select!, #code_set, #code_size, #code_superior, #code_superior_or_equal, #code_to_context, #code_to_list, #code_transform_values, #code_values
Methods inherited from Code::Object
#<=>, #==, as_json, #as_json, #call, 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, inspect, maybe, #multi_fetch, multi_fetch, #nothing?, nothing?, repeat, sig, #sig, #succ, #to_code, to_json, #to_json, to_s, truthy?, #truthy?, |
Constructor Details
#initialize(*args, **_kargs) ⇒ Context
Returns a new instance of Context.
8 9 10 11 |
# File 'lib/code/object/context.rb', line 8 def initialize(*args, **_kargs, &) super(args.first) @parent = args.second if args.second.is_a?(Dictionary) end |
Instance Attribute Details
#parent ⇒ Object (readonly)
Returns the value of attribute parent.
6 7 8 |
# File 'lib/code/object/context.rb', line 6 def parent @parent end |
Instance Method Details
#code_lookup!(identifier) ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/code/object/context.rb', line 13 def code_lookup!(identifier) code_identifier = identifier.to_code if code_has_key?(code_identifier).truthy? self elsif parent? parent.code_lookup!(code_identifier) else raise Error, "#{code_identifier} is not defined" end end |