Class: FileSourceStructure

Inherits:
SourceStructure show all
Defined in:
ext/ae-editor/ae-editor.rb

Instance Attribute Summary

Attributes inherited from SourceStructure

#root

Instance Method Summary collapse

Methods inherited from SourceStructure

#class_node_by_line, #deep_node_by_line, #node_by_line, root

Constructor Details

#initialize(_file, _row_rif = nil) ⇒ FileSourceStructure

Returns a new instance of FileSourceStructure.


100
101
102
103
104
105
# File 'ext/ae-editor/ae-editor.rb', line 100

def initialize(_file, _row_rif = nil)
  super()
  @file = _file
  @blank_rows = []
  initialize_blank_rows(_row_rif) if !_row_rif.nil?
end

Instance Method Details

#initialize_blank_rows(_row = nil) ⇒ Object


107
108
109
110
111
112
113
114
# File 'ext/ae-editor/ae-editor.rb', line 107

def initialize_blank_rows(_row = nil)
  File::open(@file,'rb'){ |file|
    file.readlines.each_with_index{| line, i | 
      @blank_rows << i+1 if line.strip == ''
    }
  }
  @blank_rows << _row if _row 
end