Class: RDL::Type::ComputedType
Instance Attribute Summary collapse
-
#code ⇒ Object
readonly
Returns the value of attribute code.
Instance Method Summary collapse
- #<=(other) ⇒ Object
- #==(other) ⇒ Object (also: #eql?)
- #compute(bind) ⇒ Object
-
#initialize(code) ⇒ ComputedType
constructor
A new instance of ComputedType.
-
#instantiate(inst) ⇒ Object
- TODO
-
Figure out how to fill in the below methods.
- #to_s ⇒ Object
- #widen ⇒ Object
Methods inherited from Type
#canonical, leq, #nil_type?, #optional?, #to_contract, #vararg?
Constructor Details
#initialize(code) ⇒ ComputedType
Returns a new instance of ComputedType.
7 8 9 10 |
# File 'lib/rdl/types/computed.rb', line 7 def initialize(code) @code = code super() end |
Instance Attribute Details
#code ⇒ Object (readonly)
Returns the value of attribute code.
5 6 7 |
# File 'lib/rdl/types/computed.rb', line 5 def code @code end |
Instance Method Details
#<=(other) ⇒ Object
36 37 38 |
# File 'lib/rdl/types/computed.rb', line 36 def <=(other) ## TODO end |
#==(other) ⇒ Object Also known as: eql?
40 41 42 |
# File 'lib/rdl/types/computed.rb', line 40 def ==(other) ## TODO end |
#compute(bind) ⇒ Object
12 13 14 15 16 |
# File 'lib/rdl/types/computed.rb', line 12 def compute(bind) res = bind.eval(@code) raise RuntimeError, "Expected ComputedType to evaluate to type, instead got #{res}." unless res.is_a?(Type) res end |
#instantiate(inst) ⇒ Object
- TODO
-
Figure out how to fill in the below methods.
I believe a ComputedType will always be evaluated to another RDL type before any of these methods would be called. Need to think about this though.
27 28 29 30 |
# File 'lib/rdl/types/computed.rb', line 27 def instantiate(inst) @inst = inst self end |
#to_s ⇒ Object
18 19 20 |
# File 'lib/rdl/types/computed.rb', line 18 def to_s "``#{@code}``" end |
#widen ⇒ Object
32 33 34 |
# File 'lib/rdl/types/computed.rb', line 32 def widen self end |