Class: DocRipper::TextRipper

Inherits:
Ripper::Base show all
Defined in:
lib/doc_ripper/text_ripper.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Ripper::Base

#initialize, #read_type

Constructor Details

This class inherits a constructor from DocRipper::Ripper::Base

Instance Attribute Details

#file_pathObject (readonly)

Returns the value of attribute file_path.



5
6
7
# File 'lib/doc_ripper/text_ripper.rb', line 5

def file_path
  @file_path
end

#text_file_pathObject (readonly)

Returns the value of attribute text_file_path.



5
6
7
# File 'lib/doc_ripper/text_ripper.rb', line 5

def text_file_path
  @text_file_path
end

Instance Method Details

#ripped?Boolean

Returns:

  • (Boolean)


7
8
9
# File 'lib/doc_ripper/text_ripper.rb', line 7

def ripped?
  @is_ripped ||=choose_ripper
end

#textObject



11
12
13
14
15
16
17
18
19
20
21
# File 'lib/doc_ripper/text_ripper.rb', line 11

def text
  if ripped? && @ripper.read_type == :file
    @text = IO.read(@text_file_path).force_encoding("ISO-8859-1").encode("utf-8", replace: nil)
    File.delete(@text_file_path)

  elsif ripped? && @ripper.read_type == :mem
    @text = @ripper.text
  end

  @text
end