class Algebrick::ProductConstructors::Abstract
Attributes
fields[R]
Public Class Methods
name()
click to toggle source
# File lib/algebrick/product_constructors/abstract.rb, line 50 def self.name @type.to_s end
new(*fields)
click to toggle source
# File lib/algebrick/product_constructors/abstract.rb, line 22 def initialize(*fields) if fields.size == 1 && fields.first.is_a?(Hash) fields = type.field_names.map { |k| fields.first[k] } end @fields = fields.zip(self.class.type.fields).map { |field, type| Type! field, type }.freeze end
to_s()
click to toggle source
# File lib/algebrick/product_constructors/abstract.rb, line 54 def self.to_s name end
type()
click to toggle source
# File lib/algebrick/product_constructors/abstract.rb, line 42 def self.type @type || raise end
type=(type)
click to toggle source
# File lib/algebrick/product_constructors/abstract.rb, line 58 def self.type=(type) Type! type, ProductVariant raise if @type @type = type include type end
Public Instance Methods
==(other)
click to toggle source
# File lib/algebrick/product_constructors/abstract.rb, line 37 def ==(other) return false unless other.kind_of? self.class @fields == other.fields end
to_a()
click to toggle source
# File lib/algebrick/product_constructors/abstract.rb, line 33 def to_a @fields end
to_ary()
click to toggle source
# File lib/algebrick/product_constructors/abstract.rb, line 29 def to_ary @fields end
type()
click to toggle source
# File lib/algebrick/product_constructors/abstract.rb, line 46 def type self.class.type end
update(*fields)
click to toggle source
# File lib/algebrick/product_constructors/abstract.rb, line 65 def update(*fields) raise NotImplementedError end