Class: Rigor::RbsExtended::PredicateEffect
- Inherits:
-
Data
- Object
- Data
- Rigor::RbsExtended::PredicateEffect
- Defined in:
- lib/rigor/rbs_extended.rb
Overview
Returned for ‘predicate-if-true` / `predicate-if-false`. `target_kind` is `:parameter` (with `target_name` the Ruby parameter symbol) or `:self`. `negative` is true when the directive uses the `~ClassName` form, in which case the engine narrows AWAY from `class_name` (`Narrowing.narrow_not_class`) instead of toward it.
‘refinement_type` is non-nil when the right-hand side is a kebab-case refinement name (`non-empty-string`, `lowercase-string`, …) instead of a Capitalised class name. The narrowing tier substitutes the carrier for the current local type; `class_name` is then nil and `negative` is false (refinement-form directives do not support `~T` negation in v0.0.4).
Instance Attribute Summary collapse
-
#class_name ⇒ Object
readonly
Returns the value of attribute class_name.
-
#edge ⇒ Object
readonly
Returns the value of attribute edge.
-
#negative ⇒ Object
readonly
Returns the value of attribute negative.
-
#refinement_type ⇒ Object
readonly
Returns the value of attribute refinement_type.
-
#target_kind ⇒ Object
readonly
Returns the value of attribute target_kind.
-
#target_name ⇒ Object
readonly
Returns the value of attribute target_name.
Instance Method Summary collapse
- #falsey_only? ⇒ Boolean
- #negative? ⇒ Boolean
- #refinement? ⇒ Boolean
-
#to_fact ⇒ Object
ADR-7 § “Slice 4-A” canonical translation.
- #truthy_only? ⇒ Boolean
Instance Attribute Details
#class_name ⇒ Object (readonly)
Returns the value of attribute class_name
62 63 64 |
# File 'lib/rigor/rbs_extended.rb', line 62 def class_name @class_name end |
#edge ⇒ Object (readonly)
Returns the value of attribute edge
62 63 64 |
# File 'lib/rigor/rbs_extended.rb', line 62 def edge @edge end |
#negative ⇒ Object (readonly)
Returns the value of attribute negative
62 63 64 |
# File 'lib/rigor/rbs_extended.rb', line 62 def negative @negative end |
#refinement_type ⇒ Object (readonly)
Returns the value of attribute refinement_type
62 63 64 |
# File 'lib/rigor/rbs_extended.rb', line 62 def refinement_type @refinement_type end |
#target_kind ⇒ Object (readonly)
Returns the value of attribute target_kind
62 63 64 |
# File 'lib/rigor/rbs_extended.rb', line 62 def target_kind @target_kind end |
#target_name ⇒ Object (readonly)
Returns the value of attribute target_name
62 63 64 |
# File 'lib/rigor/rbs_extended.rb', line 62 def target_name @target_name end |
Instance Method Details
#falsey_only? ⇒ Boolean
64 |
# File 'lib/rigor/rbs_extended.rb', line 64 def falsey_only? = edge == :falsey_only |
#negative? ⇒ Boolean
65 |
# File 'lib/rigor/rbs_extended.rb', line 65 def negative? = negative == true |
#refinement? ⇒ Boolean
66 |
# File 'lib/rigor/rbs_extended.rb', line 66 def refinement? = !refinement_type.nil? |
#to_fact ⇒ Object
ADR-7 § “Slice 4-A” canonical translation. Lifts the parser-side carrier into a ‘Rigor::FlowContribution::Fact` that the merger and plugin contribution stream consume uniformly. `class_name` lifts to `Nominal`; `refinement_type` is already a `Rigor::Type` and passes through. The `edge` field doesn’t survive the conversion —the slot it lands in (truthy_facts / falsey_facts / …) encodes that.
76 77 78 79 80 81 82 83 |
# File 'lib/rigor/rbs_extended.rb', line 76 def to_fact FlowContribution::Fact.new( target_kind: target_kind, target_name: target_name, type: refinement_type || Rigor::Type::Combinator.nominal_of(class_name), negative: negative == true ) end |
#truthy_only? ⇒ Boolean
63 |
# File 'lib/rigor/rbs_extended.rb', line 63 def truthy_only? = edge == :truthy_only |