Sha256: f2b5c701a3933497edc78eb0898657a809248acbac8d9a47eaa83184cf52cb41

Contents?: true

Size: 973 Bytes

Versions: 20

Compression:

Stored size: 973 Bytes

Contents

# frozen_string_literal: true

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

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(time: Time.now, tag:, record:)
          @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

20 entries across 20 versions & 1 rubygems

Version Path
fusuma-2.0.0.pre lib/fusuma/plugin/events/event.rb
fusuma-1.11.1 lib/fusuma/plugin/events/event.rb
fusuma-1.10.2 lib/fusuma/plugin/events/event.rb
fusuma-1.10.1 lib/fusuma/plugin/events/event.rb
fusuma-1.10.0 lib/fusuma/plugin/events/event.rb
fusuma-1.9.0 lib/fusuma/plugin/events/event.rb
fusuma-1.8.0 lib/fusuma/plugin/events/event.rb
fusuma-1.7.0 lib/fusuma/plugin/events/event.rb
fusuma-1.6.0 lib/fusuma/plugin/events/event.rb
fusuma-1.5.0 lib/fusuma/plugin/events/event.rb
fusuma-1.4.1 lib/fusuma/plugin/events/event.rb
fusuma-1.4.0 lib/fusuma/plugin/events/event.rb
fusuma-1.3.3 lib/fusuma/plugin/events/event.rb
fusuma-1.3.2 lib/fusuma/plugin/events/event.rb
fusuma-1.3.1 lib/fusuma/plugin/events/event.rb
fusuma-1.3.0 lib/fusuma/plugin/events/event.rb
fusuma-1.2.1 lib/fusuma/plugin/events/event.rb
fusuma-1.2 lib/fusuma/plugin/events/event.rb
fusuma-1.1 lib/fusuma/plugin/events/event.rb
fusuma-1.0 lib/fusuma/plugin/events/event.rb