Class: String
Instance Method Summary collapse
- #is_bool? ⇒ Boolean
- #is_f? ⇒ Boolean
- #is_i? ⇒ Boolean
- #is_time? ⇒ Boolean
- #to_bool ⇒ Object
- #to_ruby ⇒ Object
- #to_time ⇒ Object
Instance Method Details
#is_bool? ⇒ Boolean
30 31 32 33 |
# File 'lib/unresponsys/helpers.rb', line 30 def is_bool? return false unless self.length == 1 %w(T F).include?(self) end |
#is_f? ⇒ Boolean
17 18 19 |
# File 'lib/unresponsys/helpers.rb', line 17 def is_f? !!Float(self) rescue false end |
#is_i? ⇒ Boolean
12 13 14 15 |
# File 'lib/unresponsys/helpers.rb', line 12 def is_i? return false if self.include?('.') !!Integer(self) rescue false end |
#is_time? ⇒ Boolean
21 22 23 24 |
# File 'lib/unresponsys/helpers.rb', line 21 def is_time? return false if /[[:alpha:]]/.match(self).present? !!Time.parse(self) rescue false end |
#to_bool ⇒ Object
35 36 37 |
# File 'lib/unresponsys/helpers.rb', line 35 def to_bool self == 'T' end |
#to_ruby ⇒ Object
39 40 41 42 43 44 45 |
# File 'lib/unresponsys/helpers.rb', line 39 def to_ruby return self.to_i if self.is_i? return self.to_f if self.is_f? return self.to_time if self.is_time? return self.to_bool if self.is_bool? self end |