module Carbon

Carbon. The language.

rubocop:disable Metrics/LineLength

Constants

Boolean

A Boolean type for Carbon. This is used as a handy shortcut.

@api private @return [Carbon::Concrete::Type]

VERSION

The version of Carbon.

@return [::String]

Void

A Void type for Carbon. This is used as a handy shortcut.

@api private @return [Carbon::Concrete::Type]

Public Class Methods

Type(string) click to toggle source

Creates a type. This uses {Carbon::Concrete::Type}, and assumes that the parameter must be a string to be parsed.

@api public @example

type = Carbon::Type("Carbon::Boolean")
type # => #<Carbon::Concrete::Type Carbon::Boolean>

@param string [::String] The string to parse. @return [Carbon::Concrete::Type] The resulting type.

# File lib/carbon.rb, line 28
def self.Type(string)
  Carbon::Concrete::Type.from(string)
end
hash(string) click to toggle source

Hashes a given string into the format used by Carbon. The format is a Base58-encoded SHA256 digest.

@api semipublic @example

Carbon.hash("") # => "gjNT5GbSC-81KmUPncw-hzQAGV3GU-eAXafmkMP-Bw2GMHWM"

@param string [::String] The string to hash. @return [::String] The hashed string.

# File lib/carbon.rb, line 41
def self.hash(string)
  digest = (Digest::SHA2.hexdigest(string).hex << 6) ^ 0xCA5B04
  encoded = Base58.encode(digest)
  encoded.scan(/.{1,9}/).join("-").freeze
end
verbose() click to toggle source

The verboseness of Carbon. This is a global setting.

@return [::Integer] The verboseness.

# File lib/carbon.rb, line 50
def self.verbose
  @_verbose ||= 1
end
verbose=(verbose) click to toggle source

The verboseness of Carbon. This is a global setting.

@param verbose [::Integer] The new verbose level. @return [::Integer]

# File lib/carbon.rb, line 58
def self.verbose=(verbose)
  @_verbose = verbose
end