Sha256: 9d4cdf64cbf72edd7fccff04fbcbefb87736fee5cc2ea212dc05db42f25d5a70

Contents?: true

Size: 982 Bytes

Versions: 12

Compression:

Stored size: 982 Bytes

Contents

# frozen_string_literal: true

require_relative '../base'
require_relative './records/record'
require_relative './records/text_record'

module Fusuma
  module Plugin
    module Events
      # Event format
      class Event < Base
        attr_reader :time
        attr_accessor :tag, :record

        # @param time [Time]
        # @param tag [Tag]
        # @param record [String, Record]
        def initialize(tag:, record:, time: Time.now)
          super()
          @time = time
          @tag = tag
          @record = case record
                    when Records::Record
                      record
                    when String
                      Records::TextRecord.new(record)
                    else
                      raise ArgumentError,
                            '@record should be String or Record'
                    end
        end

        def inspect
          "time: #{time}, tag: #{tag}, record: #{record}"
        end
      end
    end
  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
fusuma-2.4.1 lib/fusuma/plugin/events/event.rb
fusuma-2.4.0 lib/fusuma/plugin/events/event.rb
fusuma-2.3.0 lib/fusuma/plugin/events/event.rb
fusuma-2.2.0 lib/fusuma/plugin/events/event.rb
fusuma-2.1.0 lib/fusuma/plugin/events/event.rb
fusuma-2.0.5 lib/fusuma/plugin/events/event.rb
fusuma-2.0.4 lib/fusuma/plugin/events/event.rb
fusuma-2.0.3 lib/fusuma/plugin/events/event.rb
fusuma-2.0.2 lib/fusuma/plugin/events/event.rb
fusuma-2.0.1 lib/fusuma/plugin/events/event.rb
fusuma-2.0.0 lib/fusuma/plugin/events/event.rb
fusuma-2.0.0.pre2 lib/fusuma/plugin/events/event.rb