Module: Str2Duck
- Defined in:
- lib/str2duck/config.rb,
lib/str2duck/format.rb,
lib/str2duck/parser.rb,
lib/str2duck/regexp.rb,
lib/str2duck/support.rb,
lib/str2duck/mpatch/object.rb,
lib/str2duck/mpatch/string.rb
Defined Under Namespace
Modules: Config, Format, MPatch, Regexp
Class Method Summary
collapse
Class Method Details
.activesupport ⇒ Object
4
5
6
7
8
|
# File 'lib/str2duck/parser.rb', line 4
def self.activesupport
require File.join 'active_support','time'
rescue LoadError
return false
end
|
.parse(str) ⇒ Object
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
|
# File 'lib/str2duck/parser.rb', line 10
def self.parse str
raise(ArgumentError,"invalid input, must be string like") unless str.class <= String
@@activesupport ||= activesupport
var= nil
[ :datetime, :date, :time, :true, :false, :float, :integer, :json, :yaml ].each do |method_name|
if ::Str2Duck::Config.__send__(method_name)
var= Str2Duck::Format.__send__ method_name, str
return var unless var.nil?
end
end
return str
end
|
.return_value_parse(object) ⇒ Object
4
5
6
7
8
9
10
11
12
13
14
15
|
# File 'lib/str2duck/support.rb', line 4
def return_value_parse object
case object
when nil
return false
when 0
return true
else
nil
end
end
|