Class: LineReaderV2
- Inherits:
-
Object
- Object
- LineReaderV2
- Includes:
- LogUtils::Logging
- Defined in:
- lib/textutils/reader/line_reader_v2.rb
Instance Attribute Summary collapse
-
#include_path ⇒ Object
readonly
Returns the value of attribute include_path.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#name_real_path ⇒ Object
readonly
Returns the value of attribute name_real_path.
Instance Method Summary collapse
- #each_line ⇒ Object
-
#initialize(name, include_path) ⇒ LineReaderV2
constructor
A new instance of LineReaderV2.
Constructor Details
#initialize(name, include_path) ⇒ LineReaderV2
Returns a new instance of LineReaderV2.
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/textutils/reader/line_reader_v2.rb', line 10 def initialize( name, include_path ) @name = name @include_path = include_path # map name to name_real_path # name might include !/ for virtual path (gets cut off) # e.g. at-austria!/w-wien/beers becomse w-wien/beers pos = @name.index( '!/') if pos.nil? @name_real_path = @name # not found; real path is the same as name else # cut off everything until !/ e.g. # at-austria!/w-wien/beers becomes # w-wien/beers @name_real_path = @name[ (pos+2)..-1 ] end end |
Instance Attribute Details
#include_path ⇒ Object (readonly)
Returns the value of attribute include_path.
31 32 33 |
# File 'lib/textutils/reader/line_reader_v2.rb', line 31 def include_path @include_path end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
29 30 31 |
# File 'lib/textutils/reader/line_reader_v2.rb', line 29 def name @name end |
#name_real_path ⇒ Object (readonly)
Returns the value of attribute name_real_path.
30 31 32 |
# File 'lib/textutils/reader/line_reader_v2.rb', line 30 def name_real_path @name_real_path end |
Instance Method Details
#each_line ⇒ Object
33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/textutils/reader/line_reader_v2.rb', line 33 def each_line path = "#{include_path}/#{name_real_path}.txt" reader = LineReader.new( path ) logger.info "parsing data '#{name}' (#{path})..." reader.each_line do |line| yield( line ) end ConfDb::Model::Prop.create_from_fixture!( name, path ) end |