Class: Yoda::Typing::Types::Var
- Defined in:
- lib/yoda/typing/types/var.rb
Instance Method Summary collapse
-
#initialize(label = nil, ref = nil) ⇒ Var
constructor
A new instance of Var.
- #ref ⇒ Base?
- #ref=(new_ref) ⇒ Object
- #reference? ⇒ Boolean
- #to_expression ⇒ Object
- #to_type_string ⇒ Object
Constructor Details
#initialize(label = nil, ref = nil) ⇒ Var
Returns a new instance of Var.
7 8 9 10 11 |
# File 'lib/yoda/typing/types/var.rb', line 7 def initialize(label = nil, ref = nil) @id = SecureRandom.alphanumeric(20) @label = label @ref = ref end |
Instance Method Details
#ref=(new_ref) ⇒ Object
14 15 16 17 |
# File 'lib/yoda/typing/types/var.rb', line 14 def ref=(new_ref) return if new_ref == self @ref = new_ref end |
#reference? ⇒ Boolean
19 20 21 |
# File 'lib/yoda/typing/types/var.rb', line 19 def reference? true end |
#to_expression ⇒ Object
28 29 30 |
# File 'lib/yoda/typing/types/var.rb', line 28 def to_expression ref&.to_expression || Store::TypeExpressions::UnknownType.new end |
#to_type_string ⇒ Object
32 33 34 |
# File 'lib/yoda/typing/types/var.rb', line 32 def to_type_string ref ? ref.to_type_string : "var(#{label}:#{id})" end |