class MetasploitDataModels::Search::Operation::Range

Search operation on a `Range`.

Constants

SEPARATOR

Separates beginning from end of the range.

Public Instance Methods

value=(formatted_value) click to toggle source

Sets `#value` to a `Range` composed by separating `formatted_value` by `-`.

@param formatted_value [#to_s] @return [Range<String>]

# File app/models/metasploit_data_models/search/operation/range.rb, line 25
def value=(formatted_value)
  range_arguments = formatted_value.to_s.split(SEPARATOR, 2)

  begin
    @value = Range.new(*range_arguments)
  rescue ArgumentError
    @value = formatted_value
  end

  @value
end

Private Instance Methods

ordered() click to toggle source

Validates that `#value` is a `Range` with `Range#begin` less than or equal to `Range#begin`

@return [void]

# File app/models/metasploit_data_models/search/operation/range.rb, line 42
def ordered
  if value.is_a?(Range) && value.begin > value.end
    errors.add(:value, :order, begin: value.begin.inspect, end: value.end.inspect)
  end