Class: Aniview::Interface::AnimeFile
- Includes:
- Util
- Defined in:
- lib/aniview/interface/animeio/animefile.rb
Instance Attribute Summary collapse
-
#accessible ⇒ Object
Returns the value of attribute accessible.
-
#last_modified ⇒ Object
Returns the value of attribute last_modified.
-
#path ⇒ Object
Returns the value of attribute path.
Attributes inherited from Item
Instance Method Summary collapse
-
#initialize(path_, seen: false, watched_on: 0) ⇒ 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, mounted_filesystem?, parse_format, readline
Methods inherited from Item
Constructor Details
#initialize(path_, seen: false, watched_on: 0) ⇒ AnimeFile
Returns a new instance of AnimeFile.
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 60 61 62 |
# File 'lib/aniview/interface/animeio/animefile.rb', line 17 def initialize(path_, seen: false, watched_on: 0) @watched = seen @accessible = true begin @last_modified = File::Stat.new(path_).mtime rescue Errno::ENOENT @last_modified = "0" end @watched_on = watched_on @path = path_ @attr = { "t" => "empty", "d" => 0, "D" => "0", "s" => 0, "S" => "0", "r" => 0x0, "a" => "n.a.", "v" => "", "l" => "", "f" => "", "b" => "", "w" => seen? ? "x" : " " } 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", "w" => seen? ? "x" : " " } end end |
Instance Attribute Details
#accessible ⇒ Object
Returns the value of attribute accessible.
14 15 16 |
# File 'lib/aniview/interface/animeio/animefile.rb', line 14 def accessible @accessible end |
#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.
15 16 17 |
# File 'lib/aniview/interface/animeio/animefile.rb', line 15 def path @path end |
Instance Method Details
#seen? ⇒ Boolean
68 69 70 |
# File 'lib/aniview/interface/animeio/animefile.rb', line 68 def seen? return @watched end |
#seenOn ⇒ Object
72 73 74 |
# File 'lib/aniview/interface/animeio/animefile.rb', line 72 def seenOn return @watched_on end |
#string ⇒ Object
87 88 89 |
# File 'lib/aniview/interface/animeio/animefile.rb', line 87 def string return (File.basename("#{@path}").gsub(/\s*\[.+?\]\s*/) {}).gsub(/(\.mkv)|(\.avi)|(\.mp4)/, "").gsub("_", " ").gsub(/\s*\(.+?\)\s*/) {} end |
#title ⇒ Object
64 65 66 |
# File 'lib/aniview/interface/animeio/animefile.rb', line 64 def title return @attr["t"] end |
#unwatch ⇒ Object
82 83 84 85 |
# File 'lib/aniview/interface/animeio/animefile.rb', line 82 def unwatch @watched = false @attr["w"] = " " end |
#watch ⇒ Object
76 77 78 79 80 |
# File 'lib/aniview/interface/animeio/animefile.rb', line 76 def watch @watched = true @watched_on = DateTime.now.strftime('%Q') @attr["w"] = "x" end |