Class: DirModel::Import::Path
- Inherits:
-
Object
- Object
- DirModel::Import::Path
- Defined in:
- lib/dir_model/import/path.rb
Overview
Csv
Instance Attribute Summary collapse
-
#current_path ⇒ Object
readonly
Returns the value of attribute current_path.
-
#index ⇒ Object
readonly
Returns the value of attribute index.
-
#path ⇒ Object
readonly
Returns the value of attribute path.
Instance Method Summary collapse
- #end? ⇒ Boolean
-
#initialize(dir_path) ⇒ Path
constructor
A new instance of Path.
- #next_path ⇒ Object
- #previous_path ⇒ Object
- #read_path ⇒ Object
- #reset! ⇒ Object
- #rewind ⇒ Object
- #set_position(index) ⇒ Object
- #size ⇒ Object
- #start? ⇒ Boolean
Constructor Details
#initialize(dir_path) ⇒ Path
Returns a new instance of Path.
9 10 11 12 |
# File 'lib/dir_model/import/path.rb', line 9 def initialize(dir_path) @path, @index = dir_path, -1 reset! end |
Instance Attribute Details
#current_path ⇒ Object (readonly)
Returns the value of attribute current_path.
7 8 9 |
# File 'lib/dir_model/import/path.rb', line 7 def current_path @current_path end |
#index ⇒ Object (readonly)
Returns the value of attribute index.
6 7 8 |
# File 'lib/dir_model/import/path.rb', line 6 def index @index end |
#path ⇒ Object (readonly)
Returns the value of attribute path.
5 6 7 |
# File 'lib/dir_model/import/path.rb', line 5 def path @path end |
Instance Method Details
#end? ⇒ Boolean
27 28 29 |
# File 'lib/dir_model/import/path.rb', line 27 def end? index.nil? end |
#next_path ⇒ Object
31 32 33 |
# File 'lib/dir_model/import/path.rb', line 31 def next_path ruby_path[index+1] end |
#previous_path ⇒ Object
35 36 37 38 |
# File 'lib/dir_model/import/path.rb', line 35 def previous_path return nil if index < 1 ruby_path[index-1] end |
#read_path ⇒ Object
40 41 42 43 44 45 46 |
# File 'lib/dir_model/import/path.rb', line 40 def read_path return if end? @index += 1 @current_path = ruby_path[index] set_end unless current_path current_path end |
#reset! ⇒ Object
18 19 20 21 |
# File 'lib/dir_model/import/path.rb', line 18 def reset! @index = -1 @current_path = @ruby_path = nil end |
#rewind ⇒ Object
52 53 54 |
# File 'lib/dir_model/import/path.rb', line 52 def rewind set_position(-1) end |
#set_position(index) ⇒ Object
48 49 50 |
# File 'lib/dir_model/import/path.rb', line 48 def set_position(index) @index = index end |
#size ⇒ Object
14 15 16 |
# File 'lib/dir_model/import/path.rb', line 14 def size @size ||= ruby_path.size end |
#start? ⇒ Boolean
23 24 25 |
# File 'lib/dir_model/import/path.rb', line 23 def start? index == -1 end |