Class: SampleManifestExcel::ManifestTypeList
- Inherits:
-
Object
- Object
- SampleManifestExcel::ManifestTypeList
- Includes:
- Comparable, Enumerable
- Defined in:
- app/sample_manifest_excel/sample_manifest_excel/manifest_type_list.rb
Overview
ManifestTypeList
Defined Under Namespace
Classes: ManifestType
Instance Method Summary collapse
- #<=>(other) ⇒ Object
- #by_asset_type(asset_type) ⇒ Object
- #each ⇒ Object
- #find_by(key) ⇒ Object
-
#initialize(manifest_types = {}) {|_self| ... } ⇒ ManifestTypeList
constructor
A new instance of ManifestTypeList.
-
#manifest_types ⇒ Object
Hash version of the manifest_types.yml config file.
- #to_a ⇒ Object
Constructor Details
#initialize(manifest_types = {}) {|_self| ... } ⇒ ManifestTypeList
Returns a new instance of ManifestTypeList.
10 11 12 13 |
# File 'app/sample_manifest_excel/sample_manifest_excel/manifest_type_list.rb', line 10 def initialize(manifest_types = {}) create_manifest_types(manifest_types) yield self if block_given? end |
Instance Method Details
#<=>(other) ⇒ Object
42 43 44 45 46 |
# File 'app/sample_manifest_excel/sample_manifest_excel/manifest_type_list.rb', line 42 def <=>(other) return unless other.is_a?(self.class) manifest_types <=> other.manifest_types end |
#by_asset_type(asset_type) ⇒ Object
32 33 34 35 36 37 38 39 40 |
# File 'app/sample_manifest_excel/sample_manifest_excel/manifest_type_list.rb', line 32 def by_asset_type(asset_type) return self if asset_type.blank? ManifestTypeList.new do |list| manifest_types.each do |k, manifest_type| list.manifest_types[k] = manifest_type if manifest_type.asset_type == asset_type end end end |
#each ⇒ Object
15 16 17 |
# File 'app/sample_manifest_excel/sample_manifest_excel/manifest_type_list.rb', line 15 def each(&) manifest_types.each(&) end |
#find_by(key) ⇒ Object
24 25 26 |
# File 'app/sample_manifest_excel/sample_manifest_excel/manifest_type_list.rb', line 24 def find_by(key) manifest_types[key] || manifest_types[key.to_s] end |
#manifest_types ⇒ Object
Hash version of the manifest_types.yml config file
20 21 22 |
# File 'app/sample_manifest_excel/sample_manifest_excel/manifest_type_list.rb', line 20 def manifest_types @manifest_types ||= {} end |
#to_a ⇒ Object
28 29 30 |
# File 'app/sample_manifest_excel/sample_manifest_excel/manifest_type_list.rb', line 28 def to_a manifest_types.values.collect(&:to_a) end |