Class: SampleManifestExcel::ManifestTypeList

Inherits:
Object
  • Object
show all
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

Constructor Details

#initialize(manifest_types = {}) {|_self| ... } ⇒ ManifestTypeList

Returns a new instance of ManifestTypeList

Yields:

  • (_self)

Yield Parameters:


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


41
42
43
44
45
# File 'app/sample_manifest_excel/sample_manifest_excel/manifest_type_list.rb', line 41

def <=>(other)
  return unless other.is_a?(self.class)

  manifest_types <=> other.manifest_types
end

#by_asset_type(asset_type) ⇒ Object


31
32
33
34
35
36
37
38
39
# File 'app/sample_manifest_excel/sample_manifest_excel/manifest_type_list.rb', line 31

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(&block) ⇒ Object


15
16
17
# File 'app/sample_manifest_excel/sample_manifest_excel/manifest_type_list.rb', line 15

def each(&block)
  manifest_types.each(&block)
end

#find_by(key) ⇒ Object


23
24
25
# File 'app/sample_manifest_excel/sample_manifest_excel/manifest_type_list.rb', line 23

def find_by(key)
  manifest_types[key] || manifest_types[key.to_s]
end

#manifest_typesObject


19
20
21
# File 'app/sample_manifest_excel/sample_manifest_excel/manifest_type_list.rb', line 19

def manifest_types
  @manifest_types ||= {}
end

#to_aObject


27
28
29
# File 'app/sample_manifest_excel/sample_manifest_excel/manifest_type_list.rb', line 27

def to_a
  manifest_types.values.collect(&:to_a)
end