Class: SaltParser::Swift::Parser

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Parser

Returns a new instance of Parser.



6
7
8
9
10
# File 'lib/swift/parser.rb', line 6

def initialize(options = {})
  @accounts = SaltParser::Swift::Accounts.new
  @errors   = []
  parse(options[:data])
end

Instance Attribute Details

#accountsObject (readonly)

Returns the value of attribute accounts.



4
5
6
# File 'lib/swift/parser.rb', line 4

def accounts
  @accounts
end

#errorsObject (readonly)

Returns the value of attribute errors.



4
5
6
# File 'lib/swift/parser.rb', line 4

def errors
  @errors
end

Instance Method Details

#parse(text) ⇒ Object



12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/swift/parser.rb', line 12

def parse(text)
  new_text = text.strip
  new_text << "\r\n" if new_text[-1,1] == "-"

  accounts_rows = new_text.split(/^-\r\n/)
  accounts_rows.map do |row|
       = SaltParser::Swift::Account.new
    raw_sheet = row.gsub(/\r\n(?!:)/, "")
    parse_sheet(, raw_sheet)
    @accounts << 
  end
end