Class: AnimeFile

Inherits:
Object
  • Object
show all
Defined in:
lib/aniview/interface/animeio/animefile.rb

Instance Method Summary collapse

Constructor Details

#initialize(path_, seen = false) ⇒ AnimeFile

Returns a new instance of AnimeFile.



7
8
9
10
11
12
13
14
15
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
# File 'lib/aniview/interface/animeio/animefile.rb', line 7

def initialize(path_, seen = false)
	@watched = seen
	@watched_on = 0
	@path = path_

	if (@path == "empty")
		@attr = {
			"t" => "empty",
			"d" => 0,
			"D" => "0",
			"s" => 0,
			"S" => "0",
			"r" => 0x0,
			"a" => "n.a.",
			"v" => "",
			"l" => "",
			"f" => "",
			"b" => "",
		} 
	else
		mov = FFMPEG::Movie.new(@path)

		@attr = {
			"t" => self.string,
			"d" => mov.duration,
			"D" => Format.format_duration(mov.duration),
			"s" => mov.size,
			"S" => Format.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 Method Details

#attributesObject



71
72
73
# File 'lib/aniview/interface/animeio/animefile.rb', line 71

def attributes
	return @attr
end

#pathObject



63
64
65
# File 'lib/aniview/interface/animeio/animefile.rb', line 63

def path
	return @path
end

#seen?Boolean

Returns:

  • (Boolean)


46
47
48
# File 'lib/aniview/interface/animeio/animefile.rb', line 46

def seen?
	return @watched
end

#seenOnObject



50
51
52
# File 'lib/aniview/interface/animeio/animefile.rb', line 50

def seenOn
	return @watched_on
end

#stringObject



67
68
69
# File 'lib/aniview/interface/animeio/animefile.rb', line 67

def string
	return (File.basename("#{@path}").gsub(/\s*\[.+?\]\s*/) {}).gsub(/(\.mkv)|(\.avi)|(\.mp4)/, "").gsub("_", " ").gsub(/\s*\(.+?\)\s*/) {}
end

#unwatchObject



59
60
61
# File 'lib/aniview/interface/animeio/animefile.rb', line 59

def unwatch
	@watched = false
end

#watchObject



54
55
56
57
# File 'lib/aniview/interface/animeio/animefile.rb', line 54

def watch
	@watched = true
	@watched_on = DateTime.now.strftime('%Q')
end