Class: Plextail::Line
- Inherits:
-
Object
- Object
- Plextail::Line
- Defined in:
- lib/plextail/line.rb
Constant Summary collapse
- DEFAULTS =
{ :version => '<134>1', :hostname => `hostname`.strip, :message_id => '- -' }
Instance Attribute Summary collapse
-
#file ⇒ Object
Returns the value of attribute file.
-
#hostname ⇒ Object
Returns the value of attribute hostname.
-
#message ⇒ Object
Returns the value of attribute message.
-
#message_id ⇒ Object
Returns the value of attribute message_id.
-
#process_id ⇒ Object
Returns the value of attribute process_id.
-
#raw ⇒ Object
Returns the value of attribute raw.
-
#timestamp ⇒ Object
Returns the value of attribute timestamp.
-
#token ⇒ Object
Returns the value of attribute token.
-
#version ⇒ Object
Returns the value of attribute version.
Instance Method Summary collapse
-
#initialize(file, raw) ⇒ Line
constructor
A new instance of Line.
- #to_s ⇒ Object
- #valid? ⇒ Boolean
Constructor Details
#initialize(file, raw) ⇒ Line
Returns a new instance of Line.
11 12 13 14 15 16 17 18 |
# File 'lib/plextail/line.rb', line 11 def initialize(file, raw) @file, @raw = file, raw @version = DEFAULTS[:version] = @hostname = DEFAULTS[:hostname] = DEFAULTS[:message_id] = raw.dup end |
Instance Attribute Details
#file ⇒ Object
Returns the value of attribute file.
8 9 10 |
# File 'lib/plextail/line.rb', line 8 def file @file end |
#hostname ⇒ Object
Returns the value of attribute hostname.
8 9 10 |
# File 'lib/plextail/line.rb', line 8 def hostname @hostname end |
#message ⇒ Object
Returns the value of attribute message.
8 9 10 |
# File 'lib/plextail/line.rb', line 8 def end |
#message_id ⇒ Object
Returns the value of attribute message_id.
8 9 10 |
# File 'lib/plextail/line.rb', line 8 def end |
#process_id ⇒ Object
Returns the value of attribute process_id.
8 9 10 |
# File 'lib/plextail/line.rb', line 8 def process_id @process_id end |
#raw ⇒ Object
Returns the value of attribute raw.
8 9 10 |
# File 'lib/plextail/line.rb', line 8 def raw @raw end |
#timestamp ⇒ Object
Returns the value of attribute timestamp.
8 9 10 |
# File 'lib/plextail/line.rb', line 8 def end |
#token ⇒ Object
Returns the value of attribute token.
8 9 10 |
# File 'lib/plextail/line.rb', line 8 def token @token end |
#version ⇒ Object
Returns the value of attribute version.
8 9 10 |
# File 'lib/plextail/line.rb', line 8 def version @version end |
Instance Method Details
#to_s ⇒ Object
20 21 22 23 24 25 26 27 28 |
# File 'lib/plextail/line.rb', line 20 def to_s unless valid? raise Plextail::InvalidLineError, "Missing #{missing_parts.join(', ')}" end string = parts.join(' ') "#{string.bytes.to_a.length} #{string}" end |
#valid? ⇒ Boolean
30 31 32 |
# File 'lib/plextail/line.rb', line 30 def valid? parts.all? { |part| part && part.length > 0 } end |