Class: Hackle::Event
- Inherits:
-
Object
- Object
- Hackle::Event
- Defined in:
- lib/hackle/event.rb
Defined Under Namespace
Classes: Builder
Instance Attribute Summary collapse
- #key ⇒ String readonly
- #properties ⇒ Hash{String => Object} readonly
- #value ⇒ Float? readonly
Class Method Summary collapse
Instance Method Summary collapse
- #==(other) ⇒ Object
- #error_or_nil ⇒ String?
-
#initialize(key:, value:, properties:) ⇒ Event
constructor
A new instance of Event.
- #to_s ⇒ Object
- #valid? ⇒ boolean
Constructor Details
#initialize(key:, value:, properties:) ⇒ Event
Returns a new instance of Event.
19 20 21 22 23 |
# File 'lib/hackle/event.rb', line 19 def initialize(key:, value:, properties:) @key = key @value = value @properties = properties end |
Instance Attribute Details
#key ⇒ String (readonly)
8 9 10 |
# File 'lib/hackle/event.rb', line 8 def key @key end |
#properties ⇒ Hash{String => Object} (readonly)
14 15 16 |
# File 'lib/hackle/event.rb', line 14 def properties @properties end |
#value ⇒ Float? (readonly)
11 12 13 |
# File 'lib/hackle/event.rb', line 11 def value @value end |
Class Method Details
.builder(key) ⇒ Hackle::Event::Builder
49 50 51 |
# File 'lib/hackle/event.rb', line 49 def self.builder(key) Builder.new(key) end |
Instance Method Details
#==(other) ⇒ Object
39 40 41 |
# File 'lib/hackle/event.rb', line 39 def ==(other) other.is_a?(Event) && other.key == key && other.value == value && other.properties == properties end |
#error_or_nil ⇒ String?
31 32 33 34 35 36 37 |
# File 'lib/hackle/event.rb', line 31 def error_or_nil return "Invalid event key: #{key} (expected: not empty string)" unless ValueType.not_empty_string?(key) return "Invalid event value: #{value} (expected: number)" if !value.nil? && !ValueType.number?(value) return "Invalid event properties: #{properties} (expected: Hash)" if !properties.nil? && !properties.is_a?(Hash) nil end |
#to_s ⇒ Object
43 44 45 |
# File 'lib/hackle/event.rb', line 43 def to_s "Hackle::Event(key: #{key}, value: #{value}, properties: #{properties})" end |
#valid? ⇒ boolean
26 27 28 |
# File 'lib/hackle/event.rb', line 26 def valid? error_or_nil.nil? end |