Class: StringTools::String
- Inherits:
-
Object
- Object
- StringTools::String
- Defined in:
- lib/string_tools/string.rb
Constant Summary collapse
- TRUE_VALUES =
%w(1 t T true TRUE on ON).to_set
Instance Method Summary collapse
-
#initialize(string) ⇒ String
constructor
A new instance of String.
-
#to_b ⇒ Object
Public: cast string value to boolean.
Constructor Details
#initialize(string) ⇒ String
Returns a new instance of String.
5 6 7 |
# File 'lib/string_tools/string.rb', line 5 def initialize(string) @string = string.to_s end |
Instance Method Details
#to_b ⇒ Object
Public: cast string value to boolean
Example:
StringTools::String.new('t').to_b
#=> true
Return boolean
16 17 18 |
# File 'lib/string_tools/string.rb', line 16 def to_b TRUE_VALUES.include?(@string) end |