Class: Literal::TypeError::Context
- Inherits:
-
Object
- Object
- Literal::TypeError::Context
- Defined in:
- lib/literal/errors/type_error.rb
Instance Attribute Summary collapse
-
#actual ⇒ Object
readonly
Returns the value of attribute actual.
-
#children ⇒ Object
readonly
Returns the value of attribute children.
-
#expected ⇒ Object
readonly
Returns the value of attribute expected.
-
#label ⇒ Object
readonly
Returns the value of attribute label.
-
#method ⇒ Object
readonly
Returns the value of attribute method.
-
#receiver ⇒ Object
readonly
Returns the value of attribute receiver.
Instance Method Summary collapse
- #add_child(expected: nil, **kwargs) ⇒ Object
- #descend(level = 0) {|_self, level| ... } ⇒ Object
- #fill_receiver(receiver:, method:, label: nil) ⇒ Object
-
#initialize(receiver: nil, method: nil, label: nil, expected: nil, actual: nil, parent: nil) ⇒ Context
constructor
A new instance of Context.
Constructor Details
#initialize(receiver: nil, method: nil, label: nil, expected: nil, actual: nil, parent: nil) ⇒ Context
Returns a new instance of Context.
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/literal/errors/type_error.rb', line 11 def initialize( receiver: nil, # _Nilable(Object) method: nil, # _Nilable(String) label: nil, # _Nilable(String) expected: nil, # _Nilable(_Any) actual: nil, # _Nilable(_Any) parent: nil # _Nilable(Context) ) @receiver = receiver @method = method @label = label @expected = expected @actual = actual @children = [] end |
Instance Attribute Details
#actual ⇒ Object (readonly)
Returns the value of attribute actual.
9 10 11 |
# File 'lib/literal/errors/type_error.rb', line 9 def actual @actual end |
#children ⇒ Object (readonly)
Returns the value of attribute children.
9 10 11 |
# File 'lib/literal/errors/type_error.rb', line 9 def children @children end |
#expected ⇒ Object (readonly)
Returns the value of attribute expected.
9 10 11 |
# File 'lib/literal/errors/type_error.rb', line 9 def expected @expected end |
#label ⇒ Object (readonly)
Returns the value of attribute label.
9 10 11 |
# File 'lib/literal/errors/type_error.rb', line 9 def label @label end |
#method ⇒ Object (readonly)
Returns the value of attribute method.
9 10 11 |
# File 'lib/literal/errors/type_error.rb', line 9 def method @method end |
#receiver ⇒ Object (readonly)
Returns the value of attribute receiver.
9 10 11 |
# File 'lib/literal/errors/type_error.rb', line 9 def receiver @receiver end |
Instance Method Details
#add_child(expected: nil, **kwargs) ⇒ Object
39 40 41 42 43 |
# File 'lib/literal/errors/type_error.rb', line 39 def add_child(expected: nil, **kwargs) child = self.class.new(expected:, **kwargs) expected.record_literal_type_errors(child) if expected.respond_to?(:record_literal_type_errors) @children << child end |
#descend(level = 0) {|_self, level| ... } ⇒ Object
27 28 29 30 31 |
# File 'lib/literal/errors/type_error.rb', line 27 def descend(level = 0, &blk) yield self, level @children.each { |child| child.descend(level + 1, &blk) } nil end |
#fill_receiver(receiver:, method:, label: nil) ⇒ Object
33 34 35 36 37 |
# File 'lib/literal/errors/type_error.rb', line 33 def fill_receiver(receiver:, method:, label: nil) @receiver = receiver @method = method @label = label end |