Class: Metasploit::Model::Search::Operation::Date

Inherits:
Base
  • Object
show all
Defined in:
app/models/metasploit/model/search/operation/date.rb

Overview

Search operation with Base#operator with #type ':date'. Validates that value is String that can parsed with Date.parse or already a Date.

Instance Attribute Summary

Attributes inherited from Base

#operator, #value

Instance Method Summary collapse

Methods inherited from Base

#operator_valid

Methods inherited from Base

#initialize, #valid!

Constructor Details

This class inherits a constructor from Metasploit::Model::Base

Instance Method Details

#date_valuevoid (private)

This method returns an undefined value.

Validates that Base#value is a Date.


32
33
34
35
36
# File 'app/models/metasploit/model/search/operation/date.rb', line 32

def date_value
  unless value.is_a? Date
    errors.add(:value, :unparseable_date)
  end
end

#value=(formatted_value) ⇒ Date, #to_s

Sets Base#value by type casting String to actual Date.

Parameters:

  • formatted_value (#to_s)

Returns:

  • (Date)

    if formatted_value.to_s is parseable with Date.parse.

  • (#to_s)

    formatted_value if formatted_value is not parseable with Date.parse.


19
20
21
22
23
24
25
# File 'app/models/metasploit/model/search/operation/date.rb', line 19

def value=(formatted_value)
  begin
    @value = Date.parse(formatted_value.to_s)
  rescue ArgumentError
    @value = formatted_value
  end
end