class String
Public Instance Methods
format_date_time(date_time_format)
click to toggle source
# File lib/testcentricity_web/utility_helpers.rb, line 27 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
is_float?()
click to toggle source
# File lib/testcentricity_web/utility_helpers.rb, line 45 def is_float? Float(self) && true rescue false end
is_int?()
click to toggle source
# File lib/testcentricity_web/utility_helpers.rb, line 41 def is_int? Integer(self) && true rescue false end
string_between(marker1, marker2)
click to toggle source
# File lib/testcentricity_web/utility_helpers.rb, line 23 def string_between(marker1, marker2) self[/#{Regexp.escape(marker1)}(.*?)#{Regexp.escape(marker2)}/m, 1] end
titlecase()
click to toggle source
# File lib/testcentricity_web/utility_helpers.rb, line 37 def titlecase "#{self.split.each{ |text| text.capitalize! }.join(' ')}" end
to_bool()
click to toggle source
# File lib/testcentricity_web/utility_helpers.rb, line 17 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