Class: Ibex::Runtime::Event
- Inherits:
-
Object
- Object
- Ibex::Runtime::Event
- Defined in:
- lib/ibex/runtime/event.rb
Overview
One immutable versioned parser observation.
Constant Summary collapse
- SCHEMA_VERSION =
: Integer
1- IDENTIFIER =
: String
"runtime-event"- TYPES =
%i[ start shift reduce error recover discard accept reject cst_built cst_fallback cst_reuse ].freeze
Instance Attribute Summary collapse
-
#data ⇒ Object
readonly
: Hash[String, untyped].
-
#sequence ⇒ Object
readonly
: Integer.
-
#type ⇒ Object
readonly
: Array.
Instance Method Summary collapse
-
#initialize(type:, sequence:, data:) ⇒ Event
constructor
A new instance of Event.
- #to_h ⇒ Object
Constructor Details
#initialize(type:, sequence:, data:) ⇒ Event
Returns a new instance of Event.
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/ibex/runtime/event.rb', line 21 def initialize(type:, sequence:, data:) raise ArgumentError, "unknown runtime event type #{type.inspect}" unless TYPES.include?(type) raise ArgumentError, "runtime event sequence must be positive" unless sequence.positive? @type = type @sequence = sequence @data = EventSanitizer.data(data) @document = { "ibex_runtime_event" => IDENTIFIER, "schema_version" => SCHEMA_VERSION, "sequence" => @sequence, "event" => @type.to_s.freeze, "data" => @data }.freeze #: Hash[String, untyped] freeze end |
Instance Attribute Details
#data ⇒ Object (readonly)
: Hash[String, untyped]
18 19 20 |
# File 'lib/ibex/runtime/event.rb', line 18 def data @data end |
#sequence ⇒ Object (readonly)
: Integer
17 18 19 |
# File 'lib/ibex/runtime/event.rb', line 17 def sequence @sequence end |
#type ⇒ Object (readonly)
: Array
16 17 18 |
# File 'lib/ibex/runtime/event.rb', line 16 def type @type end |
Instance Method Details
#to_h ⇒ Object
39 40 41 |
# File 'lib/ibex/runtime/event.rb', line 39 def to_h @document end |