Class: Orbacle::Builder::Context
- Inherits:
-
Object
- Object
- Orbacle::Builder::Context
- Defined in:
- lib/orbacle/builder/context.rb
Defined Under Namespace
Classes: AnalyzedKlass
Instance Attribute Summary collapse
-
#analyzed_klass ⇒ Object
readonly
Returns the value of attribute analyzed_klass.
-
#analyzed_method ⇒ Object
readonly
Returns the value of attribute analyzed_method.
-
#filepath ⇒ Object
readonly
Returns the value of attribute filepath.
-
#lenv ⇒ Object
readonly
Returns the value of attribute lenv.
-
#nesting ⇒ Object
readonly
Returns the value of attribute nesting.
-
#selfie ⇒ Object
readonly
Returns the value of attribute selfie.
Instance Method Summary collapse
- #analyzed_klass_id ⇒ Object
-
#initialize(filepath, selfie, nesting, analyzed_klass, analyzed_method, lenv) ⇒ Context
constructor
A new instance of Context.
- #lenv_fetch(key) ⇒ Object
- #merge_lenv(new_lenv) ⇒ Object
- #scope ⇒ Object
- #with_analyzed_klass(new_klass_id) ⇒ Object
- #with_analyzed_method(new_analyzed_method_id) ⇒ Object
- #with_lenv(new_lenv) ⇒ Object
- #with_merged_lenvs(lenv1, lenv2) ⇒ Object
- #with_nesting(new_nesting) ⇒ Object
- #with_selfie(new_selfie) ⇒ Object
- #with_visibility(new_visibility) ⇒ Object
Constructor Details
#initialize(filepath, selfie, nesting, analyzed_klass, analyzed_method, lenv) ⇒ Context
Returns a new instance of Context.
8 9 10 11 12 13 14 15 |
# File 'lib/orbacle/builder/context.rb', line 8 def initialize(filepath, selfie, nesting, analyzed_klass, analyzed_method, lenv) @filepath = filepath.freeze @selfie = selfie.freeze @nesting = nesting.freeze @analyzed_klass = analyzed_klass.freeze @analyzed_method = analyzed_method.freeze @lenv = lenv.freeze end |
Instance Attribute Details
#analyzed_klass ⇒ Object (readonly)
Returns the value of attribute analyzed_klass.
17 18 19 |
# File 'lib/orbacle/builder/context.rb', line 17 def analyzed_klass @analyzed_klass end |
#analyzed_method ⇒ Object (readonly)
Returns the value of attribute analyzed_method.
17 18 19 |
# File 'lib/orbacle/builder/context.rb', line 17 def analyzed_method @analyzed_method end |
#filepath ⇒ Object (readonly)
Returns the value of attribute filepath.
17 18 19 |
# File 'lib/orbacle/builder/context.rb', line 17 def filepath @filepath end |
#lenv ⇒ Object (readonly)
Returns the value of attribute lenv.
17 18 19 |
# File 'lib/orbacle/builder/context.rb', line 17 def lenv @lenv end |
#nesting ⇒ Object (readonly)
Returns the value of attribute nesting.
17 18 19 |
# File 'lib/orbacle/builder/context.rb', line 17 def nesting @nesting end |
#selfie ⇒ Object (readonly)
Returns the value of attribute selfie.
17 18 19 |
# File 'lib/orbacle/builder/context.rb', line 17 def selfie @selfie end |
Instance Method Details
#analyzed_klass_id ⇒ Object
55 56 57 |
# File 'lib/orbacle/builder/context.rb', line 55 def analyzed_klass_id analyzed_klass.klass_id end |
#lenv_fetch(key) ⇒ Object
47 48 49 |
# File 'lib/orbacle/builder/context.rb', line 47 def lenv_fetch(key) lenv.fetch(key, []) end |
#merge_lenv(new_lenv) ⇒ Object
43 44 45 |
# File 'lib/orbacle/builder/context.rb', line 43 def merge_lenv(new_lenv) self.class.new(filepath, selfie, nesting, analyzed_klass, analyzed_method, lenv.merge(new_lenv)) end |
#scope ⇒ Object
27 28 29 |
# File 'lib/orbacle/builder/context.rb', line 27 def scope nesting.to_scope end |
#with_analyzed_klass(new_klass_id) ⇒ Object
31 32 33 |
# File 'lib/orbacle/builder/context.rb', line 31 def with_analyzed_klass(new_klass_id) self.class.new(filepath, selfie, nesting, AnalyzedKlass.new(new_klass_id, :public), analyzed_method, lenv) end |
#with_analyzed_method(new_analyzed_method_id) ⇒ Object
39 40 41 |
# File 'lib/orbacle/builder/context.rb', line 39 def with_analyzed_method(new_analyzed_method_id) self.class.new(filepath, selfie, nesting, analyzed_klass, new_analyzed_method_id, lenv) end |
#with_lenv(new_lenv) ⇒ Object
51 52 53 |
# File 'lib/orbacle/builder/context.rb', line 51 def with_lenv(new_lenv) self.class.new(filepath, selfie, nesting, analyzed_klass, analyzed_method, new_lenv) end |
#with_merged_lenvs(lenv1, lenv2) ⇒ Object
59 60 61 62 63 64 65 66 67 68 |
# File 'lib/orbacle/builder/context.rb', line 59 def with_merged_lenvs(lenv1, lenv2) final_lenv = {} var_names = (lenv1.keys + lenv2.keys).uniq var_names.each do |var_name| final_lenv[var_name] = (lenv1.fetch(var_name, []) + lenv2.fetch(var_name, [])).uniq end with_lenv(final_lenv) end |
#with_nesting(new_nesting) ⇒ Object
23 24 25 |
# File 'lib/orbacle/builder/context.rb', line 23 def with_nesting(new_nesting) self.class.new(filepath, selfie, new_nesting, analyzed_klass, analyzed_method, lenv) end |
#with_selfie(new_selfie) ⇒ Object
19 20 21 |
# File 'lib/orbacle/builder/context.rb', line 19 def with_selfie(new_selfie) self.class.new(filepath, new_selfie, nesting, analyzed_klass, analyzed_method, lenv) end |
#with_visibility(new_visibility) ⇒ Object
35 36 37 |
# File 'lib/orbacle/builder/context.rb', line 35 def with_visibility(new_visibility) self.class.new(filepath, selfie, nesting, AnalyzedKlass.new(analyzed_klass.klass_id, new_visibility), analyzed_method, lenv) end |