Class: CbNitride::TitleFormatter
- Inherits:
-
Object
- Object
- CbNitride::TitleFormatter
- Defined in:
- lib/cb_nitride/title_formatter.rb
Constant Summary collapse
- LONG_PAREN_OF_PATTERN =
/[(].*[Oo][fF].*\d+.*[)]/
Instance Attribute Summary collapse
-
#raw_title ⇒ Object
Returns the value of attribute raw_title.
Instance Method Summary collapse
- #clean_long_paren_of_text ⇒ Object
- #clean_title ⇒ Object
-
#initialize(raw_title) ⇒ TitleFormatter
constructor
TODO: This really only works for variants and issues.
- #issue_number ⇒ Object
- #limited_series_max_issue ⇒ Object
- #series_title ⇒ Object
- #special_number ⇒ Object
- #variant_description ⇒ Object
Constructor Details
#initialize(raw_title) ⇒ TitleFormatter
TODO: This really only works for variants and issues.
8 9 10 |
# File 'lib/cb_nitride/title_formatter.rb', line 8 def initialize(raw_title) @raw_title = raw_title end |
Instance Attribute Details
#raw_title ⇒ Object
Returns the value of attribute raw_title.
4 5 6 |
# File 'lib/cb_nitride/title_formatter.rb', line 4 def raw_title @raw_title end |
Instance Method Details
#clean_long_paren_of_text ⇒ Object
58 59 60 |
# File 'lib/cb_nitride/title_formatter.rb', line 58 def clean_long_paren_of_text clean_title.match(LONG_PAREN_OF_PATTERN).to_s.match(/\d+/).to_s.strip.to_i end |
#clean_title ⇒ Object
62 63 64 65 |
# File 'lib/cb_nitride/title_formatter.rb', line 62 def clean_title @_clean_title ||= raw_title.gsub(/[(][C].*[)]?/, '').gsub('(MR)', '').gsub('(NET)', '').strip end |
#issue_number ⇒ Object
31 32 33 34 35 36 37 38 39 |
# File 'lib/cb_nitride/title_formatter.rb', line 31 def issue_number @_issue_number ||= match = clean_title.match(/#\d+/).to_s.gsub('#', '').strip if match.nil? || match.empty? nil else match.to_i end end |
#limited_series_max_issue ⇒ Object
41 42 43 44 45 46 47 48 |
# File 'lib/cb_nitride/title_formatter.rb', line 41 def limited_series_max_issue @_limited_series_max_issue ||= if clean_title.match(LONG_PAREN_OF_PATTERN) clean_long_paren_of_text else nil end end |
#series_title ⇒ Object
14 15 16 17 18 19 |
# File 'lib/cb_nitride/title_formatter.rb', line 14 def series_title @_series_title ||= if clean_title.include? "#" clean_title.split("#").first.strip end end |
#special_number ⇒ Object
21 22 23 24 25 26 27 28 29 |
# File 'lib/cb_nitride/title_formatter.rb', line 21 def special_number @_special_number ||= match = clean_title.match(/#\S+/).to_s.gsub('#', '').strip if match.nil? || match.empty? nil else match end end |
#variant_description ⇒ Object
50 51 52 53 54 55 56 |
# File 'lib/cb_nitride/title_formatter.rb', line 50 def variant_description @_variant_description ||= array = clean_title.split(/#\S+/) return nil if array.size == 1 string = array.last.gsub(LONG_PAREN_OF_PATTERN, '').strip string.empty? ? nil : string end |