Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

kinda

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

kinda

  • 0.1.0
  • Rubygems
  • Socket score

Version published
Maintainers
1
Created
Source

Kinda

Super basic type checking functions in ruby.

Usage

module Type
  include Kinda.module
end

Type[Float].call(1.0)
# => 1.0

Type[Float].call(1)
# => Kinda::ConstraintError: expected Float but given Fixnum

In addition to any normal Ruby class the following custom types are available.

  • Nil
  • True
  • False
  • Bool
Type[Bool].call(true)
# => true

Type[Bool].call(false)
# => false

Type[Bool].call(nil)
# => Kinda::ConstraintError: expected [TrueClass, FalseClass] but given NilClass

New types can also be defined in terms of existing types.

require 'bigdecimal'

Decimal = [BigDecimal, Float]

Type[Decimal].call(BigDecimal.new('1.0'))
# => #<BigDecimal:7fdd2c3aa9b0,'0.1E1',9(18)>

MaybeDecimal = [Nil, Decimal]

Type[MaybeDecimal].call(1.0)
# => 1.0

Type[MaybeDecimal].call(nil)
# => nil

Type[MaybeDecimal].call(1)
# => Kinda::ConstraintError: expected [NilClass, BigDecimal, Float] but given Fixnum

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/sbscully/kinda.

License

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

FAQs

Package last updated on 18 Jan 2017

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc