Class: OCR::Path

Inherits:
Object
  • Object
show all
Defined in:
lib/simple-ocr/path.rb

Constant Summary collapse

EXTENS =
{:pdf => "pdf", :png => "png"}

Instance Method Summary collapse

Constructor Details

#initialize(input_file) ⇒ Path

Initialize your Input File.



9
10
11
# File 'lib/simple-ocr/path.rb', line 9

def initialize(input_file)
	@input_file = input_file
end

Instance Method Details

#clean_image_pathString

Clean your Input File

Returns:

  • (String)

    Cleaned Image Path



39
40
41
42
43
# File 'lib/simple-ocr/path.rb', line 39

def clean_image_path
	duppath = duplicate_path
	duppath[get_filename] = "cleaned_"+name_exten[0]+".png"
	return duppath
end

#duplicate_pathString

Duplicate the input file path

Returns:

  • (String)

    input file path



23
24
25
# File 'lib/simple-ocr/path.rb', line 23

def duplicate_path
	return @input_file.dup
end

#get_filenameString

Get the FileName

Returns:

  • (String)

    Filename



48
49
50
# File 'lib/simple-ocr/path.rb', line 48

def get_filename
	File.basename(@input_file).split("/")[0]
end

#image_pathString

From PDF to Image conversion

Returns:

  • (String)

    Converted Image Path



30
31
32
33
34
# File 'lib/simple-ocr/path.rb', line 30

def image_path
	duppath = duplicate_path
	duppath[name_exten[1]] = Path::EXTENS[:png]
	return duppath
end

#name_extenArray

Split the Realname

Returns:

  • (Array)

    name and extension



16
17
18
# File 'lib/simple-ocr/path.rb', line 16

def name_exten
	File.basename(@input_file).split(".")
end