Class: Aniview::Interface::AnimeFile
- Includes:
- Util
- Defined in:
- lib/aniview/interface/animeio/animefile.rb
Instance Attribute Summary collapse
-
#last_modified ⇒ Object
Returns the value of attribute last_modified.
-
#path ⇒ Object
Returns the value of attribute path.
Instance Method Summary collapse
-
#initialize(path_, seen = false) ⇒ AnimeFile
constructor
A new instance of AnimeFile.
- #seen? ⇒ Boolean
- #seenOn ⇒ Object
- #string ⇒ Object
- #title ⇒ Object
- #unwatch ⇒ Object
- #watch ⇒ Object
Methods included from Util
decode_object, encode_object, error_message, format_duration, format_progress, format_size, parse_format, readline
Methods inherited from Item
Constructor Details
#initialize(path_, seen = false) ⇒ AnimeFile
Returns a new instance of AnimeFile.
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 |
# File 'lib/aniview/interface/animeio/animefile.rb', line 16 def initialize(path_, seen = false) @watched = seen begin @last_modified = File::Stat.new(path_).mtime rescue Errno::ENOENT @last_modified = "0" end @watched_on = 0 @path = path_ @attr = { "t" => "empty", "d" => 0, "D" => "0", "s" => 0, "S" => "0", "r" => 0x0, "a" => "n.a.", "v" => "", "l" => "", "f" => "", "b" => "", } if (@path == "empty") else mov = FFMPEG::Movie.new(@path) @attr = { "t" => self.string, "d" => mov.duration, "D" => Util.format_duration(mov.duration), "s" => mov.size, "S" => Util.format_size(mov.size), "r" => mov.resolution, "a" => mov.audio_codec, "v" => mov.video_codec, "l" => mov.colorspace, "f" => mov.frame_rate, "b" => String(mov.bitrate) + "kb/s", } end end |
Instance Attribute Details
#last_modified ⇒ Object
Returns the value of attribute last_modified.
13 14 15 |
# File 'lib/aniview/interface/animeio/animefile.rb', line 13 def last_modified @last_modified end |
#path ⇒ Object
Returns the value of attribute path.
14 15 16 |
# File 'lib/aniview/interface/animeio/animefile.rb', line 14 def path @path end |
Instance Method Details
#seen? ⇒ Boolean
65 66 67 |
# File 'lib/aniview/interface/animeio/animefile.rb', line 65 def seen? return @watched end |
#seenOn ⇒ Object
69 70 71 |
# File 'lib/aniview/interface/animeio/animefile.rb', line 69 def seenOn return @watched_on end |
#string ⇒ Object
82 83 84 |
# File 'lib/aniview/interface/animeio/animefile.rb', line 82 def string return (File.basename("#{@path}").gsub(/\s*\[.+?\]\s*/) {}).gsub(/(\.mkv)|(\.avi)|(\.mp4)/, "").gsub("_", " ").gsub(/\s*\(.+?\)\s*/) {} end |
#title ⇒ Object
61 62 63 |
# File 'lib/aniview/interface/animeio/animefile.rb', line 61 def title return @attr["t"] end |
#unwatch ⇒ Object
78 79 80 |
# File 'lib/aniview/interface/animeio/animefile.rb', line 78 def unwatch @watched = false end |
#watch ⇒ Object
73 74 75 76 |
# File 'lib/aniview/interface/animeio/animefile.rb', line 73 def watch @watched = true @watched_on = DateTime.now.strftime('%Q') end |