Class: Hookd::Interaction
- Inherits:
-
Object
- Object
- Hookd::Interaction
- Defined in:
- lib/hookd/interaction.rb
Overview
Represents a captured DNS or HTTP interaction
Instance Attribute Summary collapse
-
#data ⇒ Object
readonly
Returns the value of attribute data.
-
#source_ip ⇒ Object
readonly
Returns the value of attribute source_ip.
-
#timestamp ⇒ Object
readonly
Returns the value of attribute timestamp.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
Class Method Summary collapse
-
.from_hash(hash) ⇒ Object
Create an Interaction from API response hash.
Instance Method Summary collapse
-
#dns? ⇒ Boolean
Check if this is a DNS interaction.
-
#http? ⇒ Boolean
Check if this is an HTTP interaction.
-
#initialize(type:, timestamp:, source_ip:, data:) ⇒ Interaction
constructor
A new instance of Interaction.
- #inspect ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(type:, timestamp:, source_ip:, data:) ⇒ Interaction
Returns a new instance of Interaction.
8 9 10 11 12 13 |
# File 'lib/hookd/interaction.rb', line 8 def initialize(type:, timestamp:, source_ip:, data:) @type = type @timestamp = @source_ip = source_ip @data = data end |
Instance Attribute Details
#data ⇒ Object (readonly)
Returns the value of attribute data.
6 7 8 |
# File 'lib/hookd/interaction.rb', line 6 def data @data end |
#source_ip ⇒ Object (readonly)
Returns the value of attribute source_ip.
6 7 8 |
# File 'lib/hookd/interaction.rb', line 6 def source_ip @source_ip end |
#timestamp ⇒ Object (readonly)
Returns the value of attribute timestamp.
6 7 8 |
# File 'lib/hookd/interaction.rb', line 6 def @timestamp end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
6 7 8 |
# File 'lib/hookd/interaction.rb', line 6 def type @type end |
Class Method Details
.from_hash(hash) ⇒ Object
Create an Interaction from API response hash
16 17 18 19 20 21 22 23 |
# File 'lib/hookd/interaction.rb', line 16 def self.from_hash(hash) new( type: hash['type'], timestamp: hash['timestamp'], source_ip: hash['source_ip'], data: hash['data'] ) end |
Instance Method Details
#dns? ⇒ Boolean
Check if this is a DNS interaction
26 27 28 |
# File 'lib/hookd/interaction.rb', line 26 def dns? type == 'dns' end |
#http? ⇒ Boolean
Check if this is an HTTP interaction
31 32 33 |
# File 'lib/hookd/interaction.rb', line 31 def http? type == 'http' end |
#inspect ⇒ Object
39 40 41 42 |
# File 'lib/hookd/interaction.rb', line 39 def inspect "#<Hookd::Interaction:#{object_id.to_s(16)} @type=#{type.inspect}, @timestamp=#{.inspect}, " \ "@source_ip=#{source_ip.inspect}, @data=#{data.inspect}>" end |
#to_s ⇒ Object
35 36 37 |
# File 'lib/hookd/interaction.rb', line 35 def to_s "#<Hookd::Interaction type=#{type} timestamp=#{} source_ip=#{source_ip}>" end |