Module: Imagechan

Defined in:
lib/imagechan.rb,
lib/imagechan/version.rb

Constant Summary collapse

VERSION =
"0.2.3"

Class Method Summary collapse

Class Method Details

.clearlockObject



32
33
34
35
36
37
38
39
# File 'lib/imagechan.rb', line 32

def self.clearlock
	if File.exists?(File.join(Imagechan.dir,"LOCK"))
		File.delete File.join(Imagechan.dir,"LOCK") 
		puts "LOCK cleared!"
	else
		puts "There are nothing to unlock"
	end
end

.dirObject



10
11
12
# File 'lib/imagechan.rb', line 10

def self.dir
	return File.join(Dir.home,'.imagechan')
end

.get_folder_name_by_id(id) ⇒ Object



22
23
24
25
# File 'lib/imagechan.rb', line 22

def self.get_folder_name_by_id(id)
	dir = Dir[File.join(Imagechan.dir,"*","#{id}*")].first.split(File::SEPARATOR).last
	return dir
end

.id_exists?(id) ⇒ Boolean

Returns:

  • (Boolean)


14
15
16
17
18
19
20
# File 'lib/imagechan.rb', line 14

def self.id_exists?(id)
	if Dir[File.join(Imagechan.dir,"*","#{id}*")].size > 0
		return true
	else
		return false
	end
end

.match_thread_url(url) ⇒ Object



41
42
43
44
45
46
47
# File 'lib/imagechan.rb', line 41

def self.match_thread_url(url)
	if url.match(/http:\/\/boards\.4chan\.org\/[a-z]+\/res\/[0-9]+/)
		true
	else
		false
	end
end

.prepareObject



27
28
29
30
# File 'lib/imagechan.rb', line 27

def self.prepare
	puts "Preparing directory"
	Dir.mkdir(Imagechan.dir)
end

.versionObject



3
4
5
# File 'lib/imagechan/version.rb', line 3

def self.version
	return VERSION
end

.where?Boolean

Returns:

  • (Boolean)


49
50
51
# File 'lib/imagechan.rb', line 49

def self.where?
	puts Imagechan.dir
end