Ruby has Integer(...) and Float(...), but does it have Boolean(…) for things like:
Boolean(ENV[“SOME_FLAG”])
What's the Ruby idiom here?
Ruby has Integer(...) and Float(...), but does it have Boolean(…) for things like:
Boolean(ENV[“SOME_FLAG”])
What's the Ruby idiom here?
@jc00ke @getajobmike Since ENV isn't a hash, it could theoretically specialize on string formats like this, letting it return numbers or booleans.
FLAG=true SIDEKIQ_WORKERS=5
ENV.boolean("FLAG") # => true
ENV.boolean("UNSET_FLAG") # => nil
ENV.integer("SIDEKIQ_WORKERS") # => 5
https://gist.github.com/jgaskins/de1f724e980ce29e31ac90eb2b5bab1f