CircleCI: https://hub.docker.com/r/circleci/ruby/tags?page=1&ordering=last_updated
Gemfile
:
gem "debug", ">= 1.0.0"
Application or test code:
debugger
~/.gemrc
gem: --no-document
$ mkdir my-project
$ cd my-project
$ git init .
$ npx gitignore ruby
$ bundle init
To create a gem see Ruby Gems
Date
: date onlyTime
: dates and times, and DST, but doesn’t handle historic calendar reforms. Active Support adds time zoneDateTime
: handles historic calendar reforms, but not DST. Deprecatedhttps://stackoverflow.com/questions/1261329/difference-between-datetime-and-time-in-ruby
Time.now
Time.parse('...')
Info on time zones on Rails
alias new_name old_name
(has to be statically defined; not symbols, just the method names)alias_attribute :new_name, :old_name
(allows dynamic)delegate :method, to: :other_object
.map(&:method)
- &
passes a Proc
as a block. Since it is given a symbol instead of a block, it calls #to_proc
on the symbol first. Symbol#to_proc
creates a Proc
that corresponds to the method with the name of the symbol.<<
- terminator must not be indented<<-
- can indent terminator, other indentation preserved<<~
- squiggly heredoc: The indentation of the least-indented line will be removed from each line of the content./cat/ =~ "dog and cat" # => 8
"dog and cat" =~ /cat/ # => 8
new_str = str.sub(/Cat/, "Gerbil") # one
new_str2 = str.gsub(/a/, "*") # global
match_data = /cat/.match("dog and cat")
https://www.ruby-lang.org/en/news/2020/12/25/ruby-3-0-0-released/
&.
<<~
Hash#dig
#yield_self
#then
an alias for #yield_self
Enumerable#filter
Fiber#scheduler
lightweight concurrency=>
def method = …
)# safest to nest modules every time you reference them
# best
module A
class B
end
end
# riskier
class A::B
end
::
approach