# File lib/algebrick/product_constructors/named.rb, line 48 def self.type=(type) super(type) raise unless type.field_names? end
# File lib/algebrick/product_constructors/named.rb, line 23 def pretty_print(q) q.group(1, "#{self.class.type.name}[", ']') do type.field_names.each_with_index do |name, i| if i == 0 q.breakable '' else q.text ',' q.breakable ' ' end q.text name.to_s q.text ':' q.group(1) do q.breakable ' ' q.pp self[name] end end end end
# File lib/algebrick/product_constructors/named.rb, line 42 def to_hash type.field_names.inject({}) { |h, name| h.update name => self[name] } end
# File lib/algebrick/product_constructors/named.rb, line 18 def to_s "#{self.class.type.name}[" + type.field_names.map { |name| "#{name}: #{self[name].to_s}" }.join(', ') +']' end
# File lib/algebrick/product_constructors/named.rb, line 53 def update(fields) type[to_hash.merge fields] end