Sha256: ef2e1416b0e062436e66aecbf43da9c43d05e6c9f9dc73c42e54744dc1e5cf39

Contents?: true

Size: 387 Bytes

Versions: 5

Compression:

Stored size: 387 Bytes

Contents

module LogParser
  class LineItem < Struct.new(:timestamp, :type, :prefix, :message)
    def to_s
      s = "[#{timestamp}] "
      s << "#{type}: " if type
      s << "[#{prefix}] " if prefix
      s << "#{message}"
      s
    end

    def full_message
      prefix ? "[#{prefix}] #{message}" : message
    end

    def <=>(other)
      timestamp <=> other.timestamp
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
log_parser-1.2.0 lib/log_parser/line_item.rb
log_parser-1.1.1 lib/log_parser/line_item.rb
log_parser-1.1.0 lib/log_parser/line_item.rb
log_parser-1.0.0 lib/log_parser/line_item.rb
log_parser-0.1.0 lib/log_parser/line_item.rb