Class: LineReaderV2
- Inherits:
-
Object
- Object
- LineReaderV2
- Includes:
- LogUtils::Logging
- Defined in:
- lib/textutils/reader/line_reader.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.
47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 |
# File 'lib/textutils/reader/line_reader.rb', line 47 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.
68 69 70 |
# File 'lib/textutils/reader/line_reader.rb', line 68 def include_path @include_path end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
66 67 68 |
# File 'lib/textutils/reader/line_reader.rb', line 66 def name @name end |
#name_real_path ⇒ Object (readonly)
Returns the value of attribute name_real_path.
67 68 69 |
# File 'lib/textutils/reader/line_reader.rb', line 67 def name_real_path @name_real_path end |
Instance Method Details
#each_line ⇒ Object
70 71 72 73 74 75 76 77 78 79 80 81 82 |
# File 'lib/textutils/reader/line_reader.rb', line 70 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 ## fix: move Prop table to props gem - why? why not?? WorldDb::Models::Prop.create_from_fixture!( name, path ) end |