Sha256: 7c2573501dc61abf054f8a5f8248c30af7ca1685ce2258526f25c69a0762813d

Contents?: true

Size: 671 Bytes

Versions: 3

Compression:

Stored size: 671 Bytes

Contents

module Xi
  class Event
    attr_reader :value, :start, :duration

    def initialize(value, start=0, duration=1)
      @value = value
      @start = start
      @duration = duration
    end

    def self.[](*args)
      new(*args)
    end

    def ==(o)
      self.class == o.class &&
        value == o.value &&
        start == o.start &&
        duration == o.duration
    end

    def end
      @start + @duration
    end

    def p(dur=nil, **metadata)
      [self].p(dur, metadata)
    end

    def inspect
      "E[#{@value.inspect},#{@start}" \
        "#{",#{@duration}" if @duration != 1}]"
    end

    def to_s
      inspect
    end
  end
end

E = Xi::Event

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
xi-lang-0.1.3 lib/xi/event.rb
xi-lang-0.1.2 lib/xi/event.rb
xi-lang-0.1.0 lib/xi/event.rb