Class: Parasort::Atom

Inherits:
Object
  • Object
show all
Defined in:
lib/parasort.rb

Constant Summary collapse

SIZE =
ENV['PARASORT_ATOM_SIZE'].to_i.yield_self{ |n| n > 0 ? n : 10000 }

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(path) ⇒ Atom

Returns a new instance of Atom.



75
76
77
78
# File 'lib/parasort.rb', line 75

def initialize(path)
  @path = path
  @range = File.basename(@path).split('_').map(&:to_i)
end

Instance Attribute Details

#pathObject (readonly)

Returns the value of attribute path.



71
72
73
# File 'lib/parasort.rb', line 71

def path
  @path
end

#rangeObject (readonly)

Returns the value of attribute range.



71
72
73
# File 'lib/parasort.rb', line 71

def range
  @range
end

Instance Method Details

#each(&block) ⇒ Object



85
86
87
# File 'lib/parasort.rb', line 85

def each(&block)
  File.foreach(@path, &block)
end

#move_to_dir(dir) ⇒ Object



80
81
82
83
# File 'lib/parasort.rb', line 80

def move_to_dir(dir)
  FileUtils.mv(@path, dir)
  @path = File.join(dir, File.basename(@path))
end