Class: SaltParser::Swift::Parser
- Inherits:
-
Object
- Object
- SaltParser::Swift::Parser
- Defined in:
- lib/swift/parser.rb
Instance Attribute Summary collapse
-
#accounts ⇒ Object
readonly
Returns the value of attribute accounts.
-
#errors ⇒ Object
readonly
Returns the value of attribute errors.
Instance Method Summary collapse
-
#initialize(options = {}) ⇒ Parser
constructor
A new instance of Parser.
- #parse(text) ⇒ Object
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( = {}) @accounts = SaltParser::Swift::Accounts.new @errors = [] parse([:data]) end |
Instance Attribute Details
#accounts ⇒ Object (readonly)
Returns the value of attribute accounts.
4 5 6 |
# File 'lib/swift/parser.rb', line 4 def accounts @accounts end |
#errors ⇒ Object (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| account = SaltParser::Swift::Account.new raw_sheet = row.gsub(/\r\n(?!:)/, "") parse_sheet(account, raw_sheet) @accounts << account end end |