Class: Dif::Reader
- Inherits:
-
Object
- Object
- Dif::Reader
- Defined in:
- lib/dif.rb,
lib/dif/line_helpers.rb
Constant Summary collapse
- ALLOWED_COMMANDS =
%w(EOD BOT)
Instance Attribute Summary collapse
-
#column_count ⇒ Object
readonly
Returns the value of attribute column_count.
-
#csv ⇒ Object
readonly
Returns the value of attribute csv.
-
#lines ⇒ Object
readonly
Returns the value of attribute lines.
-
#rows_count ⇒ Object
readonly
Returns the value of attribute rows_count.
Instance Method Summary collapse
- #export_csv ⇒ Object
-
#initialize(file, encoding = "IBM850") ⇒ Reader
constructor
A new instance of Reader.
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_count ⇒ Object (readonly)
Returns the value of attribute column_count.
31 32 33 |
# File 'lib/dif.rb', line 31 def column_count @column_count end |
#csv ⇒ Object (readonly)
Returns the value of attribute csv.
31 32 33 |
# File 'lib/dif.rb', line 31 def csv @csv end |
#lines ⇒ Object (readonly)
Returns the value of attribute lines.
31 32 33 |
# File 'lib/dif.rb', line 31 def lines @lines end |
#rows_count ⇒ Object (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_csv ⇒ Object
45 46 47 |
# File 'lib/dif.rb', line 45 def export_csv @csv.string end |