Class: HistogramArray

Inherits:
Object
  • Object
show all
Defined in:
app/controllers/surveyor_gui/reports_controller.rb

Instance Method Summary collapse

Constructor Details

#initialize(question, in_arr, label = nil) ⇒ HistogramArray

Returns a new instance of HistogramArray.



269
270
271
272
273
274
275
276
277
278
279
280
# File 'app/controllers/surveyor_gui/reports_controller.rb', line 269

def initialize(question, in_arr, label=nil)
  @out_arr = []
  p "in arr at init #{in_arr.map{|a| a}}"
  @in_arr = in_arr.map{|a| a.response_value}
  return if in_arr.empty?
  @question = question
  set_min
  set_max
  set_count
  set_distribution
  set_step
end

Instance Method Details

#calculateObject



282
283
284
285
286
287
288
289
290
291
292
293
294
# File 'app/controllers/surveyor_gui/reports_controller.rb', line 282

def calculate
  if !@in_arr.empty?
    @distribution.times do |index|
      refresh_range
      set_x_label
      @out_arr[index]= {
        :x => @x_label,
        :y => @in_arr.select {|v| v.to_f >= @lower_bound && v.to_f < @upper_bound}.count
      }
    end
  end
  return @out_arr
end