Class: String
Class Method Summary collapse
- .to_ruby(object) ⇒ Object (also: to_parse)
Instance Method Summary collapse
Class Method Details
.to_ruby(object) ⇒ Object Also known as: to_parse
14 15 16 |
# File 'lib/opium/extensions/string.rb', line 14 def to_ruby(object) object.to_s if object end |
Instance Method Details
#to_bool ⇒ Object
2 3 4 5 6 |
# File 'lib/opium/extensions/string.rb', line 2 def to_bool return true if self == true || self =~ (/^(true|t|yes|y|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 |
#to_geo_point ⇒ Object
8 9 10 11 |
# File 'lib/opium/extensions/string.rb', line 8 def to_geo_point return GeoPoint.new( self.split(',').map {|c| c.to_f} ) if self =~ /^[+-]?\d+(\.\d+)?\s*,\s*[+-]?\d+(\.\d+)?$/ raise ArgumentError.new("invalid value for GeoPoint: \"#{self}\"") end |