Class: Bmg::Operator::Autosummarize::Check

Inherits:
Object
  • Object
show all
Defined in:
lib/bmg/operator/autosummarize.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#sumsObject (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