Class: Bmg::Operator::Autosummarize::Check
- Inherits:
-
Object
- Object
- Bmg::Operator::Autosummarize::Check
- Defined in:
- lib/bmg/operator/autosummarize.rb
Instance Attribute Summary collapse
-
#sums ⇒ Object
readonly
Returns the value of attribute sums.
Instance Method Summary collapse
- #init(tuple) ⇒ Object
-
#initialize(sums) ⇒ Check
constructor
A new instance of Check.
- #sum(memo, tuple) ⇒ Object
- #summarizer(k) ⇒ Object
- #term(tuple) ⇒ Object
Constructor Details
#initialize(sums) ⇒ Check
Returns a new instance of Check.
120 121 122 |
# File 'lib/bmg/operator/autosummarize.rb', line 120 def initialize(sums) @sums = sums end |
Instance Attribute Details
#sums ⇒ Object (readonly)
Returns the value of attribute sums.
123 124 125 |
# File 'lib/bmg/operator/autosummarize.rb', line 123 def sums @sums end |
Instance Method Details
#init(tuple) ⇒ Object
129 130 131 132 133 |
# File 'lib/bmg/operator/autosummarize.rb', line 129 def init(tuple) tuple.each_with_object({}){|(k,v),h| h.merge!(k => summarizer(k).init(v)) } end |
#sum(memo, tuple) ⇒ Object
135 136 137 138 139 |
# File 'lib/bmg/operator/autosummarize.rb', line 135 def sum(memo, tuple) tuple.each_with_object(memo.dup){|(k,v),h| h.merge!(k => summarizer(k).sum(h[k], v)) } end |
#summarizer(k) ⇒ Object
125 126 127 |
# File 'lib/bmg/operator/autosummarize.rb', line 125 def summarizer(k) @sums[k] ||= Same::INSTANCE end |
#term(tuple) ⇒ Object
141 142 143 144 145 |
# File 'lib/bmg/operator/autosummarize.rb', line 141 def term(tuple) tuple.each_with_object({}){|(k,v),h| h.merge!(k => summarizer(k).term(v)) } end |