Class: Schatz::Input::IncrLineParser
- Includes:
- ParserHelper
- Defined in:
- lib/schatz/input/incr_line_parser.rb
Constant Summary
Constants included from ParserHelper
ParserHelper::CONVERSATION_HTML, ParserHelper::CONVERSATION_ROW, ParserHelper::GCM_NUMBER, ParserHelper::IP_ADDRESS, ParserHelper::LINK, ParserHelper::LINK_HTML, ParserHelper::ONE_HYPHEN, ParserHelper::ONE_OR_MORE_COMMA, ParserHelper::ONE_PORT, ParserHelper::PORTS_WITH_PROTOCOL, ParserHelper::REGEXP_HOST, ParserHelper::REGEXP_HOST_PORTS, ParserHelper::SOURCE_SUBNET
Instance Attribute Summary
Attributes inherited from Parser
Instance Method Summary collapse
-
#initialize(lines) ⇒ IncrLineParser
constructor
A new instance of IncrLineParser.
- #parse(line) ⇒ Object
Methods included from ParserHelper
#parse_ports_field, #push_connection
Constructor Details
#initialize(lines) ⇒ IncrLineParser
Returns a new instance of IncrLineParser.
5 6 7 |
# File 'lib/schatz/input/incr_line_parser.rb', line 5 def initialize(lines) super(lines) end |
Instance Method Details
#parse(line) ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/schatz/input/incr_line_parser.rb', line 9 def parse(line) case line when IncrExport::LINK_HTML @links << Connection.new do |c| c.gcm = $1.downcase c.scheme = $2 c.host = $3 c.port = $4.to_i if $4 end when IncrExport::CONVERSATION_HTML gcm = $1 scheme = $4 line.scan(IP_ADDRESS).map do |address| parse_ports_field(line.match(IncrExport::PORTS_WITH_PROTOCOL).captures.first).map do |port| @connections << Connection.new do |c| c.gcm = gcm c.scheme = scheme c.host = address.first c.port = port.to_i end end end end end |