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

sloth

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

sloth

  • 0.1
  • Rubygems
  • Socket score

Version published
Maintainers
1
Created
Source

Sloth

Sloth is a Ruby gem that implements the lazy() function as robustly as possible.

Installation

gem install sloth

Usage

require 'sloth'
obj = lazy{:sloth}
obj.to_s # => 'sloth'

Hunting Sloths

Sloths can only (easily) be detected by the sloth? method.

sloth = lazy{:sloth}

sloth.sloth?       # => true
sloth.class        # => Symbol
:sloth.sloth?      # => false
sloth.is_a?(Sloth) # => false
Sloth === sloth    # => false

The evaluated? method can tell whether a Sloth has been evaluated.

sloth = lazy{'sloth'}

sloth.evaluated? # => false
"lazy #{sloth}s"
sloth.evaluated? # => true

nil and false

Unfortunately, Ruby doesn't provide any easy way to override the behavior of if, so

if lazy{false}
	puts('fail')
else
	puts('success')
end

will puts('fail'). A workaround has been implemented via the self() method, which has been defined on Object. Therefore,

if lazy{false}.self
	puts('fail')
else
	puts('success')
end

will puts('success').

License

Sloth is in the public domain.

FAQs

Package last updated on 08 May 2012

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