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) ⇒ 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.
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 |
# File 'lib/aniview/interface/animeio/animefile.rb', line 17 def initialize(path_, seen = false) @watched = seen @accessible = true 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
#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
67 68 69 |
# File 'lib/aniview/interface/animeio/animefile.rb', line 67 def seen? return @watched end |
#seenOn ⇒ Object
71 72 73 |
# File 'lib/aniview/interface/animeio/animefile.rb', line 71 def seenOn return @watched_on end |
#string ⇒ Object
84 85 86 |
# File 'lib/aniview/interface/animeio/animefile.rb', line 84 def string return (File.basename("#{@path}").gsub(/\s*\[.+?\]\s*/) {}).gsub(/(\.mkv)|(\.avi)|(\.mp4)/, "").gsub("_", " ").gsub(/\s*\(.+?\)\s*/) {} end |
#title ⇒ Object
63 64 65 |
# File 'lib/aniview/interface/animeio/animefile.rb', line 63 def title return @attr["t"] end |
#unwatch ⇒ Object
80 81 82 |
# File 'lib/aniview/interface/animeio/animefile.rb', line 80 def unwatch @watched = false end |
#watch ⇒ Object
75 76 77 78 |
# File 'lib/aniview/interface/animeio/animefile.rb', line 75 def watch @watched = true @watched_on = DateTime.now.strftime('%Q') end |