Module: Alf::Algebra::Operator
- Extended by:
- Support::Registry
- Includes:
- Operand
- Included in:
- Autonum, Clip, Coerce, Compact, Defaults, Extend, Generator, Group, InferHeading, Intersect, Join, Matching, Minus, NotMatching, Project, Quota, Rank, Rename, Restrict, Sort, Summarize, TypeSafe, Ungroup, Union, Unwrap, Wrap
- Defined in:
- lib/alf-algebra/alf/algebra/operator.rb
Defined Under Namespace
Modules: ClassMethods
Instance Attribute Summary collapse
Attributes included from Support::Bindable
Class Method Summary collapse
-
.included(mod) ⇒ Object
Installs the class methods needed on all operators.
Instance Method Summary collapse
- #==(other) ⇒ Object
-
#bind(connection) ⇒ Object
Binds to a connection.
- #dup(&bl) ⇒ Object
-
#initialize(*args) ⇒ Object
Create an operator instance.
-
#signature ⇒ Signature
The operator signature.
-
#to_lispy ⇒ Object
(also: #to_s)
-> to_xxx.
- #to_relvar ⇒ Object
-
#with_operands(*operands) ⇒ Object
identity and pseudo-mutability.
Methods included from Support::Registry
each, listen, listeners, register, registered
Methods included from Operand
#attr_list, coerce, #heading, #keys, #to_cog, #to_dot, #to_relation
Methods included from Support::Bindable
Instance Attribute Details
#operands ⇒ Object
44 45 46 |
# File 'lib/alf-algebra/alf/algebra/operator.rb', line 44 def operands @operands end |
Class Method Details
.included(mod) ⇒ Object
Installs the class methods needed on all operators
33 34 35 36 37 38 |
# File 'lib/alf-algebra/alf/algebra/operator.rb', line 33 def included(mod) super mod.extend(ClassMethods) mod.extend(Classification) register(mod, Operator) end |
Instance Method Details
#==(other) ⇒ Object
89 90 91 92 93 94 |
# File 'lib/alf-algebra/alf/algebra/operator.rb', line 89 def ==(other) (other.object_id == self.object_id) || ((other.class == self.class) && (other.operands == self.operands) && (other.signature.collect_on(self) == self.signature.collect_on(self))) end |
#bind(connection) ⇒ Object
Binds to a connection
52 53 54 |
# File 'lib/alf-algebra/alf/algebra/operator.rb', line 52 def bind(connection) super{|c| c.operands = operands.map{|op| op.bind(connection) } } end |
#dup(&bl) ⇒ Object
85 86 87 |
# File 'lib/alf-algebra/alf/algebra/operator.rb', line 85 def dup(&bl) bl.nil? ? super : super.tap(&bl) end |
#initialize(*args) ⇒ Object
Create an operator instance
47 48 49 |
# File 'lib/alf-algebra/alf/algebra/operator.rb', line 47 def initialize(*args) signature.parse_args(args, self) end |
#signature ⇒ Signature
Returns the operator signature.
57 58 59 |
# File 'lib/alf-algebra/alf/algebra/operator.rb', line 57 def signature self.class.signature end |
#to_lispy ⇒ Object Also known as: to_s
-> to_xxx
63 64 65 66 67 68 69 |
# File 'lib/alf-algebra/alf/algebra/operator.rb', line 63 def to_lispy cmdname = self.class.rubycase_name oper, args, opts = signature.collect_on(self) args = opts.empty? ? (oper + args) : (oper + args + [ opts ]) args = args.map{|arg| Support.to_lispy(arg) } "#{cmdname}(#{args.join(', ')})" end |
#to_relvar ⇒ Object
72 73 74 |
# File 'lib/alf-algebra/alf/algebra/operator.rb', line 72 def to_relvar Relvar::Virtual.new(self, connection) end |
#with_operands(*operands) ⇒ Object
identity and pseudo-mutability
78 79 80 81 82 83 |
# File 'lib/alf-algebra/alf/algebra/operator.rb', line 78 def with_operands(*operands) dup{|copy| copy.operands = operands copy.clean_computed_attributes! } end |