crystal_plus
Version, currently 0.1.45 versions
github.com/mosop/crystal_plus
An extension of the Crystal standard library.
5 stars
6 dependents
License: MIT
Installation
# Add this to your shard.yml
dependencies:
crystal_plus:
github: mosop/crystal_plus
version: ~> 0.1.4Then run:
shards installshard.yml
- Crystal
0.23.1- License
- MIT
- Author
- mosop
Dependencies
This version declares no dependencies.
README
Crystal Plus
An extension of the Crystal standard library.
Installation
Add this to your application's shard.yml:
dependencies:
crystal_plus:
github: mosop/crystal_plus
Index
- Dir
- .tmp : makes a uniquely-named and temporary directory
- NamedTuple
- String
- #empty_to_nil : returns nil if empty
Dir
.tmp
Makes a uniquely-named directory and yields a passed block with the directory's path. The directory is to be deleted before this method returns.
Dir.tmp do |dir|
# The dir argument points to a new temporary directory.
end
# The directory is already deleted here.
Parameters
- base : a base directory's path whose a temporary directory will be created (default:
"/tmp") - cleanup : whether to delete a created temporary directory before .tmp returns (default:
true)
NamedTuple
#to_h?
def test_to_h(**options)
options.to_h
end
test_to_h # compile error
require "cyrstal_plus/named_tuple/#to_h?"
def test_to_h?(**options)
options.to_h?
end
test_to_h? # => nil
#merge
require "cyrstal_plus/named_tuple/#merge"
def merge(tuple, **options)
tuple.merge(options)
end
def reverse_merge(tuple, **options)
options.merge(tuple)
end
smile = {face: ":)"}
frown = {face: ":("}
other = {other: ":P"}
merge(smile) # => {face: ":)"}
merge(smile, **frown) # => {face: ":("}
merge(smile, **other) # => ArgumentError
reverse_merge(smile) # => ArgumentError
String
#empty_to_nil
Returns nil if self is empty. Otherwise, self.
require "cyrstal_plus/string/#empty_to_nil"
"abc".empty_to_nil # => "abc"
"".empty_to_nil # => nil
Release Notes
- v0.1.2
- String#empty_to_nil
- v0.1.1
- Dir.tmp
Contributing
- Fork it ( https://github.com/mosop/crystal_plus/fork )
- Create your feature branch (git checkout -b my-new-feature)
- Commit your changes (git commit -am 'Add some feature')
- Push to the branch (git push origin my-new-feature)
- Create a new Pull Request
Contributors
- mosop - creator, maintainer
Documentation
Built from the current release. The first visit to a release nobody has asked for starts its build.
Links
This release
- Version
0.1.4- Tagged
- Jul 25, 2017
- Commit
c82a7028ef00- Crystal
0.23.1- Indexed
- yes
Dependents
Repository
github.com/mosop/crystal_plus
Metadata
- Created
- Aug 12, 2026
- Updated
- Sep 22, 2026
- Synced
- Sep 22, 2026
- Versions
- 5