Class: StringTools::String

Inherits:
Object
  • Object
show all
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

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_bObject

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