Class: Dif::Reader

Inherits:
Object
  • Object
show all
Defined in:
lib/dif.rb,
lib/dif/line_helpers.rb

Constant Summary collapse

ALLOWED_COMMANDS =
%w(EOD BOT)

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(file, encoding = "IBM850") ⇒ Reader

Returns a new instance of Reader.



34
35
36
37
38
39
40
41
42
43
# File 'lib/dif.rb', line 34

def initialize(file, encoding="IBM850")
	@lines = ::File.read(file, :external_encoding => encoding, :internal_encoding => "UTF-8").lines
	@csv = CSV.new("", col_sep: "\t")
	@line_buffer=Array.new
	fix_lines
	set_rows
	set_columns
	@lines.slice! 0..data_section_start_at_line
	read_data
end

Instance Attribute Details

#column_countObject (readonly)

Returns the value of attribute column_count.



31
32
33
# File 'lib/dif.rb', line 31

def column_count
  @column_count
end

#csvObject (readonly)

Returns the value of attribute csv.



31
32
33
# File 'lib/dif.rb', line 31

def csv
  @csv
end

#linesObject (readonly)

Returns the value of attribute lines.



31
32
33
# File 'lib/dif.rb', line 31

def lines
  @lines
end

#rows_countObject (readonly)

Returns the value of attribute rows_count.



31
32
33
# File 'lib/dif.rb', line 31

def rows_count
  @rows_count
end

Instance Method Details

#export_csvObject



45
46
47
# File 'lib/dif.rb', line 45

def export_csv
	@csv.string
end