class TypeProf::Core::Type::Record
Attributes
Public Class Methods
Source
# File bundled-src/typeprof-0.31.1/lib/typeprof/core/type.rb, line 245 def initialize(genv, fields, base_type) @fields = fields @base_type = base_type raise unless base_type.is_a?(Instance) end
Public Instance Methods
Source
# File bundled-src/typeprof-0.31.1/lib/typeprof/core/type.rb, line 266 def base_type(genv) @base_type end
Source
# File bundled-src/typeprof-0.31.1/lib/typeprof/core/type.rb, line 253 def get_value(key = nil) if key # Return specific field value if it exists @fields[key] elsif @fields.empty? # Empty record has no values nil else # Return union of all field values if no specific key @base_type.args[1] end end
Source
# File bundled-src/typeprof-0.31.1/lib/typeprof/core/type.rb, line 270 def show field_strs = @fields.map do |key, val_vtx| "#{ key }: #{ Type.strip_parens(val_vtx.show) }" end "{ #{ field_strs.join(", ") } }" end