class String

Public Instance Methods

format_date_time(date_time_format) click to toggle source
# File lib/testcentricity/utility_helpers.rb, line 23
def format_date_time(date_time_format)
  return if self.blank?
  new_date = DateTime.parse(self)
  if ENV['LOCALE'] && date_time_format.is_a?(Symbol)
    I18n.l(new_date, format: date_time_format)
  else
    new_date.strftime(date_time_format)
  end
end
string_between(marker1, marker2) click to toggle source
# File lib/testcentricity/utility_helpers.rb, line 19
def string_between(marker1, marker2)
  self[/#{Regexp.escape(marker1)}(.*?)#{Regexp.escape(marker2)}/m, 1]
end
to_bool() click to toggle source
# File lib/testcentricity/utility_helpers.rb, line 13
def to_bool
  return true if self == true || self =~ (/(true|t|yes|y|x|1)$/i)
  return false if self == false || self.blank? || self =~ (/(false|f|no|n|0)$/i)
  raise ArgumentError.new("invalid value for Boolean: \"#{self}\"")
end