Class: ToBarGraph::Bucketizer

Inherits:
Object
  • Object
show all
Defined in:
lib/bucketizer.rb

Instance Method Summary collapse

Constructor Details

#initialize(data) ⇒ Bucketizer

Returns a new instance of Bucketizer.



5
6
7
# File 'lib/bucketizer.rb', line 5

def initialize(data)
  @data = data
end

Instance Method Details

#create_bucketsObject

Raises:

  • (ArgumentError)


9
10
11
12
13
14
15
# File 'lib/bucketizer.rb', line 9

def create_buckets
  return create_buckets_from_hash if(@data.is_a?(Hash))

  return create_buckets_from_array if(@data.is_a?(Array))

  raise ArgumentError, "You need to provide either an Array or a Hash"
end