module Barometer::Support::Matchers::Formats

Public Instance Methods

_find_regex(format) click to toggle source
# File lib/barometer/support/matchers/formats.rb, line 11
def _find_regex(format)
  case format
  when :time
    /^\d{1,4}-\d{1,2}-\d{1,2} \d{2}:\d{2}:\d{2} [\-\+\d]{5}$/i
  when :optional_string
    /^[\w \.-]*$/i
  when :string
    /^[\w \.,-]{2,}$/i
  when :number
    /^\d{1,3}$/i
  when :float
    /^[\d\.]{1,5}$/i
  when :temperature
    /^-?[0-9\.]{1,20}[ ]?[cfCF]?$/i
  when :pressure
    /^[0-9\.]{1,20}[ ]?[a-zA-Z]{0,3}$/i
  when :vector
    /^[0-9\.]{1,20} (?:mph|kph) (?:[nesw]{1,3}(?:orth|outh|t|ast)?|@ [0-9\.]{1,5} degrees)$/i
  when :distance
    /^[0-9\.]{1,20}[ ]?k?m?$/i
  when Regexp
    format
  end
end
is_of_format?(format, value) click to toggle source
# File lib/barometer/support/matchers/formats.rb, line 7
def is_of_format?(format, value)
  value.match(_find_regex(format))
end