Class: BaaChan::TradeParser

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

Instance Method Summary collapse

Constructor Details

#initialize(lines, layout) ⇒ TradeParser



47
48
49
50
# File 'lib/baa_chan/parser.rb', line 47

def initialize(lines, layout)
  @lines = lines
  @layout = layout
end

Instance Method Details

#parseObject



52
53
54
55
56
57
58
59
60
61
# File 'lib/baa_chan/parser.rb', line 52

def parse
  @lines.each_with_object([]) do |line, trades|
    next unless line.include? @layout.trade_prefix

    @asset = line.include?('OPCAO') ? 'option' : 'stock'

    @trade_line = line
    trades << Trade.new(operation, ticker, quantity, price)
  end
end