0.0
No release in over a year
Returns a symbol based on the given argument.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Project Readme

Kernel#Symbol

Returns a Symbol based on the given argument.

Status

Version Yard documentation Ruby License

Installation

Add this line to your application's Gemfile:

gem "kernel-symbol"

And then execute:

bundle install

Or install it yourself as:

gem install kernel-symbol

Usage

If the argument is a symbol, returns the symbol. If the argument is not a symbol, tries to convert to a symbol.

In all other cases, returns an error.

Example

require "kernel/symbol"

Symbol(:foo)            # => :foo
Symbol("foo")           # => :foo
Symbol(true)            # => :true
Symbol(42)              # => :"42"
Symbol(BasicObject.new) # TypeError (can't convert BasicObject into String)

Note

The #Symbol method could be used similarly to the methods already present in the Kernel module:

  • #Array
  • #Complex
  • #Float
  • #Hash
  • #Integer
  • #Rational
  • #String

Warning

The Kernel module is included in the Object class, so by loading this library, the #Symbol method will be available in every Ruby object.

Versioning

Kernel#Symbol uses Semantic Versioning 2.0.0

See also

License

The gem is available as open source under the terms of the MIT License.