Class: CbNitride::CategorySorter
- Inherits:
-
Object
- Object
- CbNitride::CategorySorter
- Defined in:
- lib/cb_nitride/category_sorter.rb
Constant Summary collapse
- ISSUE_CODE =
"1"- COLLECTION_CODE =
"3"- MERCHANDISE_CODES =
["2", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14", "15", "16"]
Instance Attribute Summary collapse
-
#hash ⇒ Object
readonly
Returns the value of attribute hash.
Instance Method Summary collapse
-
#initialize(hash) ⇒ CategorySorter
constructor
A new instance of CategorySorter.
- #is_collection? ⇒ Boolean
- #is_issue? ⇒ Boolean
- #is_merch? ⇒ Boolean
- #is_variant? ⇒ Boolean
- #sort ⇒ Object
Constructor Details
#initialize(hash) ⇒ CategorySorter
Returns a new instance of CategorySorter.
10 11 12 |
# File 'lib/cb_nitride/category_sorter.rb', line 10 def initialize(hash) @hash = hash end |
Instance Attribute Details
#hash ⇒ Object (readonly)
Returns the value of attribute hash.
8 9 10 |
# File 'lib/cb_nitride/category_sorter.rb', line 8 def hash @hash end |
Instance Method Details
#is_collection? ⇒ Boolean
49 50 51 52 53 54 55 56 57 |
# File 'lib/cb_nitride/category_sorter.rb', line 49 def is_collection? return @is_collection unless @is_collection.nil? @is_collection = true if hash[:title].include?(" GN ") @is_collection = true if hash[:title].include?(" TP ") @is_collection = true if hash[:title].match(/\s(VOL)\s\d+/) @is_collection = false if hash[:title].match(/\s[#]\d+/) @is_collection = false if @is_collection.nil? return @is_collection end |
#is_issue? ⇒ Boolean
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/cb_nitride/category_sorter.rb', line 33 def is_issue? return @is_issue unless @is_issue.nil? if specific_issue_patterns(hash[:title]) @is_issue = true elsif is_variant? @is_issue = false elsif is_collection? @is_issue = false elsif is_merch? @is_issue = false else @is_issue = true end return @is_issue end |
#is_merch? ⇒ Boolean
59 60 61 62 63 64 65 66 67 68 |
# File 'lib/cb_nitride/category_sorter.rb', line 59 def is_merch? return @is_merch unless @is_merch.nil? case hash[:creators] when "" @is_merch = true else @is_merch = false end return @is_merch end |
#is_variant? ⇒ Boolean
22 23 24 25 26 27 28 29 30 31 |
# File 'lib/cb_nitride/category_sorter.rb', line 22 def is_variant? return @is_variant unless @is_variant.nil? @is_variant = true if hash[:title].include? "VAR ED" @is_variant = true if hash[:title].include? "COMBO PACK" @is_variant = true if hash[:title].include? "STANDARD ED" @is_variant = true if hash[:title].match(/(CVR)\s[B-Z]/) @is_variant = true if specific_issue_patterns(hash[:title]) @is_variant = false if @is_variant.nil? return @is_variant end |
#sort ⇒ Object
14 15 16 17 18 19 20 |
# File 'lib/cb_nitride/category_sorter.rb', line 14 def sort return hash[:category_code] unless hash[:category_code].nil? return ISSUE_CODE if is_variant? return COLLECTION_CODE if is_collection? return "16" if is_merch? return ISSUE_CODE if is_issue? end |