Sha256: 61c7ad023e565889a76254c04cff2b6b5bb53fa22091b9dfa799d2c00eb92c44
Contents?: true
Size: 1.01 KB
Versions: 8
Compression:
Stored size: 1.01 KB
Contents
# redefine method in Object class class Object def number? to_f.to_s == to_s || to_i.to_s == to_s end def to_num return to_f if to_f.to_s == to_s return to_i if to_i.to_s == to_s end def character? (start_with? '#\\') && (('a'..'z').to_a.include? self[2]) && size == 3 end def string? return false unless self.class == String (start_with? '"') && (end_with? '"') && (size != 1) end def list? return false if size < 3 check_for_list end def pair? res = object_split if is_a? String res = to_a if is_a? Array return true if res[-3] == '.' list? && !res[2..-2].empty? end def quote? return true if start_with? '\'' false end private def object_split result = to_s.split(/(\(|\)|\.)|\ /) result.delete('') result end def check_for_list res = to_a if is_a? Array res = object_split if is_a? String res[0..1].join == '\'(' && res[-1] == ')' && res[-3] != '.' end end
Version data entries
8 entries across 8 versions & 1 rubygems