class Uberous::Uber

Attributes

data_collection[R]
error_data_collection[R]
version[R]

Public Class Methods

new(data_collection = [], error_data_collection = [], version = '1.0') click to toggle source
# File lib/uberous/uber.rb, line 4
def initialize(data_collection = [], error_data_collection = [], version = '1.0')
  @data_collection = data_collection
  @error_data_collection = error_data_collection
  @version = version
end

Public Instance Methods

add_data(data) click to toggle source
# File lib/uberous/uber.rb, line 10
def add_data(data)
  @data_collection << data
end
add_error_data(data) click to toggle source
# File lib/uberous/uber.rb, line 14
def add_error_data(data)
  @error_data_collection << data
end
to_hash() click to toggle source
# File lib/uberous/uber.rb, line 23
def to_hash
  data = @data_collection.map(&:to_hash)
  error = @error_data_collection.map(&:to_hash)
  uber = { version: @version }
  uber[:data] = data unless data.empty?
  uber[:error] = error unless error.empty?
  { uber: uber }
end