Class: Wool::SexpAnalysis::Protocols::ClassProtocol
- Defined in:
- lib/wool/analysis/protocols.rb
Overview
A protocol that has the same signatures as a given class.
Instance Attribute Summary collapse
-
#class_used ⇒ Object
readonly
Returns the value of attribute class_used.
Instance Method Summary collapse
-
#<=>(other) ⇒ -1, ...
Compares two ClassProtocols.
-
#initialize(klass) ⇒ ClassProtocol
constructor
Initializes the class protocol with the given class.
-
#signatures ⇒ Array<Signature>
Returns all the signatures that the class responds to, since this protocol has the same signatures.
Constructor Details
#initialize(klass) ⇒ ClassProtocol
Initializes the class protocol with the given class.
56 57 58 |
# File 'lib/wool/analysis/protocols.rb', line 56 def initialize(klass) @class_used = klass end |
Instance Attribute Details
#class_used ⇒ Object (readonly)
Returns the value of attribute class_used.
51 52 53 |
# File 'lib/wool/analysis/protocols.rb', line 51 def class_used @class_used end |
Instance Method Details
#<=>(other) ⇒ -1, ...
Compares two ClassProtocols. Has a short-circuit check if two protocols refer to the same class or not. Otherwise, it has to check the signatures.
65 66 67 68 69 70 |
# File 'lib/wool/analysis/protocols.rb', line 65 def <=>(other) if ClassProtocol === other && self.class_used == other.class_used then return 0 else self.signatures <=> other.signatures end end |
#signatures ⇒ Array<Signature>
Returns all the signatures that the class responds to, since this protocol has the same signatures.
76 77 78 |
# File 'lib/wool/analysis/protocols.rb', line 76 def signatures @class_used.signatures end |