Class: LogExtractor::Hit

Inherits:
Object
  • Object
show all
Defined in:
lib/log_extractor/hit.rb

Instance Method Summary collapse

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method_name, *_args, &_block) ⇒ Object



7
8
9
10
# File 'lib/log_extractor/hit.rb', line 7

def method_missing(method_name, *_args, &_block)
  value = source[method_name.to_s]
  value.nil? ? super : value
end

Instance Method Details

#respond_to_missing?(method_name, *_args) ⇒ Boolean

Returns:

  • (Boolean)


12
13
14
# File 'lib/log_extractor/hit.rb', line 12

def respond_to_missing?(method_name, *_args)
  !source[method_name.to_s].nil?
end

#timestampObject



16
17
18
# File 'lib/log_extractor/hit.rb', line 16

def timestamp
  DateTime.rfc3339(source["@timestamp"]).to_time
end