Class: FileNameInfo
- Inherits:
-
Object
- Object
- FileNameInfo
- Defined in:
- lib/file_name_info.rb
Instance Attribute Summary collapse
-
#episode ⇒ Object
Returns the value of attribute episode.
-
#location ⇒ Object
Returns the value of attribute location.
-
#name ⇒ Object
Returns the value of attribute name.
-
#raw_name ⇒ Object
Returns the value of attribute raw_name.
-
#series ⇒ Object
Returns the value of attribute series.
-
#year ⇒ Object
Returns the value of attribute year.
Instance Method Summary collapse
- #<=>(other) ⇒ Object
-
#initialize(params = {}) ⇒ FileNameInfo
constructor
A new instance of FileNameInfo.
- #to_s ⇒ Object
Constructor Details
#initialize(params = {}) ⇒ FileNameInfo
Returns a new instance of FileNameInfo.
4 5 6 7 8 9 10 11 |
# File 'lib/file_name_info.rb', line 4 def initialize(params = {}) @name = params[:name] @year = params[:year] @raw_name = params[:raw_name] @location = params[:location] @series = params[:series] @episode = params[:episode] end |
Instance Attribute Details
#episode ⇒ Object
Returns the value of attribute episode.
2 3 4 |
# File 'lib/file_name_info.rb', line 2 def episode @episode end |
#location ⇒ Object
Returns the value of attribute location.
2 3 4 |
# File 'lib/file_name_info.rb', line 2 def location @location end |
#name ⇒ Object
Returns the value of attribute name.
2 3 4 |
# File 'lib/file_name_info.rb', line 2 def name @name end |
#raw_name ⇒ Object
Returns the value of attribute raw_name.
2 3 4 |
# File 'lib/file_name_info.rb', line 2 def raw_name @raw_name end |
#series ⇒ Object
Returns the value of attribute series.
2 3 4 |
# File 'lib/file_name_info.rb', line 2 def series @series end |
#year ⇒ Object
Returns the value of attribute year.
2 3 4 |
# File 'lib/file_name_info.rb', line 2 def year @year end |
Instance Method Details
#<=>(other) ⇒ Object
27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/file_name_info.rb', line 27 def <=>(other) if series && other.series && series != other.series return (series <=> other.series) elsif episode && other.episode && episode != other.episode return (episode <=> other.episode) elsif name != other.name return (name <=> other.name) elsif year && other.year #Note: with year we want newest first return (other.year <=> year) else return 0 end end |
#to_s ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/file_name_info.rb', line 13 def to_s s = '' if @name s += @name s += " (#{@year})" if @year s += " S: #{@series} E: #{@episode}" if @series || @episode elsif @raw_name s += @raw_name else s += @location end s end |