Class: TF2LineParser::Line
- Inherits:
-
Object
- Object
- TF2LineParser::Line
- Defined in:
- lib/tf2_line_parser/line.rb
Instance Attribute Summary collapse
-
#line ⇒ Object
Returns the value of attribute line.
Instance Method Summary collapse
-
#initialize(line) ⇒ Line
constructor
A new instance of Line.
- #parse ⇒ Object
Constructor Details
#initialize(line) ⇒ Line
Returns a new instance of Line.
11 12 13 |
# File 'lib/tf2_line_parser/line.rb', line 11 def initialize(line) @line = line end |
Instance Attribute Details
#line ⇒ Object
Returns the value of attribute line.
9 10 11 |
# File 'lib/tf2_line_parser/line.rb', line 9 def line @line end |
Instance Method Details
#parse ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/tf2_line_parser/line.rb', line 15 def parse Events::Event.types.each do |type| begin match = line.match(type.regex) rescue ArgumentError tidied_line = ActiveSupport::Multibyte::Chars.new(line).tidy_bytes match = tidied_line.match(type.regex) end if match @match ||= type.new(*type.regex_results(match)) break end end @match end |