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.
119 120 121 122 123 |
# File 'lib/apple_data/data_file.rb', line 119 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
125 126 127 |
# File 'lib/apple_data/data_file.rb', line 125 def data @collection_data end |
#sort! ⇒ Object
129 130 131 132 133 134 135 136 |
# File 'lib/apple_data/data_file.rb', line 129 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 |