Class: Algebrick::ProductConstructors::Basic
- Inherits:
-
Abstract
show all
- Defined in:
- lib/algebrick/product_constructors/basic.rb
Instance Attribute Summary
Attributes inherited from Abstract
#fields
Class Method Summary
collapse
Instance Method Summary
collapse
Methods inherited from Abstract
#==, #initialize, name, #to_a, #to_ary, to_s, type, #type
Methods included from TypeCheck
#Child!, #Child?, #Match!, #Match?, #Type!, #Type?
Methods included from Value
#==, #inspect, #type
Methods included from Matching
#any, #match, #match?, #on
Class Method Details
.type=(type) ⇒ Object
37
38
39
40
|
# File 'lib/algebrick/product_constructors/basic.rb', line 37
def self.type=(type)
super(type)
raise if type.field_names?
end
|
Instance Method Details
#pretty_print(q) ⇒ Object
23
24
25
26
27
28
29
30
31
32
33
34
35
|
# File 'lib/algebrick/product_constructors/basic.rb', line 23
def pretty_print(q)
q.group(1, "#{self.class.type.name}[", ']') do
fields.each_with_index do |value, i|
if i == 0
q.breakable ''
else
q.text ','
q.breakable ' '
end
q.pp value
end
end
end
|
18
19
20
21
|
# File 'lib/algebrick/product_constructors/basic.rb', line 18
def to_s
"#{self.class.type.name}[" +
fields.map(&:to_s).join(', ') + ']'
end
|
#update(fields) ⇒ Object
42
43
44
|
# File 'lib/algebrick/product_constructors/basic.rb', line 42
def update(fields)
type[*fields]
end
|