Class: String
- Inherits:
-
Object
- Object
- String
- Defined in:
- lib/constructor_core/string.rb
Instance Method Summary collapse
Instance Method Details
#accusative ⇒ Object
23 24 25 |
# File 'lib/constructor_core/string.rb', line 23 def accusative self.sub(/(.*)ая( ?)/, '\1ую\2').sub(/(.*)а( (.+))?$/, '\1у\2').sub(/(.*)я( (.+))?$/, '\1ю\2') end |
#boolean? ⇒ Boolean
9 10 11 12 13 14 15 |
# File 'lib/constructor_core/string.rb', line 9 def boolean? if self =~ (/(true|yes)$/i) || self =~ (/(false|no)$/i) return true else return false end end |
#numeric? ⇒ Boolean
4 5 6 7 |
# File 'lib/constructor_core/string.rb', line 4 def numeric? return true if self =~ /^\d+$/ true if Float(self) rescue false end |
#to_boolean ⇒ Object
17 18 19 20 21 |
# File 'lib/constructor_core/string.rb', line 17 def to_boolean 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 |