lib/meibo/data_set.rb in meibo-0.1.0 vs lib/meibo/data_set.rb in meibo-0.2.0
- old
+ new
@@ -1,10 +1,13 @@
module Meibo
class DataSet
- def initialize(data)
+ attr_reader :roster
+
+ def initialize(data, roster:)
@data = data
@data_hash = data.to_h {|datum| [datum.sourced_id, datum] }
+ @roster = roster
end
def <<(new_data)
raise DataNotFoundError, "sourcedIdがありません" unless new_data.sourced_id
raise SourcedIdDuplicatedError, 'sourcedIdが重複しています' if @data_hash.key?(new_data.sourced_id)
@@ -29,10 +32,10 @@
def empty?
@data.empty?
end
- def find_by_sourced_id(sourced_id)
+ def find(sourced_id)
@data_hash.fetch(sourced_id)
rescue KeyError
raise DataNotFoundError, "sourcedId: #{sourced_id} が見つかりません"
end