Method: Lotus::Utils::Kernel.String

Defined in:
lib/lotus/utils/kernel.rb,
lib/lotus/utils/kernel.rb

.String(arg) ⇒ Object

Since:

  • 0.1.1



652
653
654
655
656
657
658
659
660
661
662
663
# File 'lib/lotus/utils/kernel.rb', line 652

def self.String(arg)
  case arg
  when ->(a) { a.respond_to?(:to_str) }
    arg.to_str
  when ->(a) { a.respond_to?(:to_s) }
    arg.to_s
  else
    super(arg)
  end
rescue NoMethodError
  raise TypeError.new "can't convert #{inspect_type_error(arg)}into String"
end