Class: GaussianParser::Processors::AtomProcessor

Inherits:
Object
  • Object
show all
Defined in:
lib/gaussian_parser/processors/atom_processor.rb

Instance Method Summary collapse

Constructor Details

#initialize(raw_data) ⇒ AtomProcessor

raw_data

[‘ 1 33 0 -2.280632 2.669338 -0.574359’,

'         2         33           0        1.077846    1.968882   -0.934420']


11
12
13
# File 'lib/gaussian_parser/processors/atom_processor.rb', line 11

def initialize(raw_data)
  @raw_data = raw_data
end

Instance Method Details

#processObject



15
16
17
18
19
20
21
22
23
# File 'lib/gaussian_parser/processors/atom_processor.rb', line 15

def process
  @raw_data.inject({}) do |memo,line|
    atom_index, atom_periodic_number = line
      .split(/\s+/)
      .reject {|e| e == '' }[0..1]
    memo[atom_index] = Utils::PeriodicTable.symbol_by_periodic_number(atom_periodic_number)
    memo
  end
end