Class: AppleData::DataFile::DataFileCollection
- Inherits:
-
Object
- Object
- AppleData::DataFile::DataFileCollection
- Defined in:
- lib/apple_data/data_file.rb
Overview
A specific "collection" inside a data file. Collections are enumerable groups of one type of item. The schema of each item is the same within a collection.
Instance Method Summary collapse
- #data ⇒ Object
-
#initialize(data_file, collection_name) ⇒ DataFileCollection
constructor
A new instance of DataFileCollection.
- #sort! ⇒ Object
Constructor Details
#initialize(data_file, collection_name) ⇒ DataFileCollection
Returns a new instance of DataFileCollection.
104 105 106 107 108 |
# File 'lib/apple_data/data_file.rb', line 104 def initialize(data_file, collection_name) @data_file = data_file @collection_name = collection_name @collection_data = @data_file.data[@collection_name] end |
Instance Method Details
#data ⇒ Object
110 111 112 |
# File 'lib/apple_data/data_file.rb', line 110 def data @collection_data end |
#sort! ⇒ Object
114 115 116 117 118 119 120 121 |
# File 'lib/apple_data/data_file.rb', line 114 def sort! case @collection_data when Array @collection_data.sort when Hash @collection_data = @collection_data.sort_by { |key, _value| key }.to_h end end |