Class: Addic7ed::VideoFile
- Inherits:
-
Object
- Object
- Addic7ed::VideoFile
- Defined in:
- lib/addic7ed/video_file.rb
Constant Summary collapse
- TVSHOW_REGEX =
/\A(?<showname>.*\w)[\[\. ]+S?(?<season>\d{1,2})[-\. ]?[EX]?(?<episode>\d{2})([-\. ]?[EX]?\d{2})*[\]\. ]+(?<tags>.*)-(?<group>\w*)\[?(?<distribution>\w*)\]?(\.\w{3})?\z/i
Instance Attribute Summary collapse
-
#distribution ⇒ Object
readonly
Returns the value of attribute distribution.
-
#episode ⇒ Object
readonly
Returns the value of attribute episode.
-
#filename ⇒ Object
readonly
Returns the value of attribute filename.
-
#group ⇒ Object
readonly
Returns the value of attribute group.
-
#season ⇒ Object
readonly
Returns the value of attribute season.
-
#showname ⇒ Object
readonly
Returns the value of attribute showname.
-
#tags ⇒ Object
readonly
Returns the value of attribute tags.
Instance Method Summary collapse
- #basename ⇒ Object
-
#initialize(filename) ⇒ VideoFile
constructor
A new instance of VideoFile.
- #inspect ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(filename) ⇒ VideoFile
Returns a new instance of VideoFile.
8 9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/addic7ed/video_file.rb', line 8 def initialize(filename) @filename = filename if match = TVSHOW_REGEX.match(basename) @showname = match[:showname] @season = match[:season].to_i @episode = match[:episode].to_i @tags = match[:tags].upcase.split(/[\. ]/) @group = match[:group].upcase @distribution = match[:distribution].upcase else raise InvalidFilename end end |
Instance Attribute Details
#distribution ⇒ Object (readonly)
Returns the value of attribute distribution.
6 7 8 |
# File 'lib/addic7ed/video_file.rb', line 6 def distribution @distribution end |
#episode ⇒ Object (readonly)
Returns the value of attribute episode.
6 7 8 |
# File 'lib/addic7ed/video_file.rb', line 6 def episode @episode end |
#filename ⇒ Object (readonly)
Returns the value of attribute filename.
6 7 8 |
# File 'lib/addic7ed/video_file.rb', line 6 def filename @filename end |
#group ⇒ Object (readonly)
Returns the value of attribute group.
6 7 8 |
# File 'lib/addic7ed/video_file.rb', line 6 def group @group end |
#season ⇒ Object (readonly)
Returns the value of attribute season.
6 7 8 |
# File 'lib/addic7ed/video_file.rb', line 6 def season @season end |
#showname ⇒ Object (readonly)
Returns the value of attribute showname.
6 7 8 |
# File 'lib/addic7ed/video_file.rb', line 6 def showname @showname end |
#tags ⇒ Object (readonly)
Returns the value of attribute tags.
6 7 8 |
# File 'lib/addic7ed/video_file.rb', line 6 def @tags end |
Instance Method Details
#basename ⇒ Object
22 23 24 |
# File 'lib/addic7ed/video_file.rb', line 22 def basename @basename ||= ::File.basename(@filename) end |
#inspect ⇒ Object
30 31 32 33 34 35 36 37 38 |
# File 'lib/addic7ed/video_file.rb', line 30 def inspect "Guesses for #{@filename}: show: #{@showname} season: #{@season} episode: #{@episode} tags: #{@tags} group: #{@group} distribution: #{@distribution}" end |
#to_s ⇒ Object
26 27 28 |
# File 'lib/addic7ed/video_file.rb', line 26 def to_s @filename end |