core-ext

Personal but versatile core class extensions
0.3.0 Latest release released
maiha/core-ext.cr
maiha

core-ext.cr Build Status

Personal but versatile core class extensions for Crystal.

  • crystal: 0.26.1

BREAKING CHANGES

  • 0.3.0: Removed Time.parse(String), use pretty.cr

API

  • Enumerable#grep(T) : Array(T)
  • String#first?(Regex) : String?
  • String?#any? : Bool
  • Time::Span.parse(String) : Time::Span

Usage

require "core-ext"

Enumerable#grep(T)

a = [1, nil, "a"]  # Array(Int32 | String | Nil)
a.grep(String)     # => ["a"] (Array(String))

String#first?(Regex)

"a:12".first?(/(\d+)/)  # => "12"

String?#any?

nil.any?           # => false
"".any?            # => false
" ".any?           # => true

Time::Span.parse(String)

Time::Span.parse("01:02:03")       # => Time::Span.new(1, 2, 3)
Time::Span.parse("5.01:02:03")     # => Time::Span.new(5, 1, 2, 3)
Time::Span.parse("5.01:02:03.010") # => Time::Span.new(5, 1, 2, 3, 10)

Installation

Add this to your application's shard.yml:

dependencies:
  core-ext:
    github: maiha/core-ext.cr
    version: 0.3.0

Development

make

Contributing

  1. Fork it ( https://github.com/maiha/core-ext.cr/fork )
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create a new Pull Request

Contributors

  • maiha maiha - creator, maintainer
core-ext:
  github: maiha/core-ext.cr
  version: ~> 0.3.0
License MIT
Crystal none

Authors

Dependencies 0

Development Dependencies 0

Dependents 1

Last synced .
search fire star recently