Sha256: 5488ed049aa697245978fd6a0141e70f1b2bcf5c9dacd4975bd3bd9f5d74929d
Contents?: true
Size: 1.26 KB
Versions: 1
Compression:
Stored size: 1.26 KB
Contents
module Str2Duck::Matcher extend self def datetime?(obj) answer_value= nil [ /^\w+, \d+ \w+ \d+ \d\d:\d\d:\d\d \+\d+$/, /^-?\d+-\d\d-\d\d\w\d\d:\d\d:\d\d\+\d\d:\d\d$/, /\w+ \w+ \d+ \d+ \d+:\d+:\d+ \w+\+\d+ \(\w+\)/, /^-?\d+-\d\d?-\d\d?\w\d\d?:\d\d?:\d\d?\w$/ ].each do |regexp| answer_value ||= obj =~ regexp end return !!answer_value end def date?(obj) answer_value= nil [ /^\d+-\d\d-\d\d$/, /^\w+, \d+ \w+ \d+$/ ].each do |regexp| answer_value ||= obj =~ regexp end return !!answer_value end def time?(obj) answer_value= nil [ /^\d+-\d\d-\d\d \d\d:\d\d:\d\d \+\d+$/ ].each do |regexp| answer_value ||= obj =~ regexp end return !!answer_value end def true?(obj) return !!(obj =~ /^true$/) end def false?(obj) return !!(obj =~ /^false$/) end def float?(obj) case obj.to_s when /^\d+\.\d+$/, /^\d+,\d+$/ return true else return false end end def integer?(obj) return !!(obj =~ /^\d+$/) end def json?(obj) return false unless defined?(JSON) begin JSON.parse(obj) return true rescue ::JSON::ParserError return false end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
str2duck-2.0.0 | lib/str2duck/matcher.rb |