In programming languages, literals are textual representations of values in the source code. This is a syntactical concept.
Some examples:
7 # integer literal| require 'io/console' | |
| require 'pty' | |
| command = ARGV.join(' ') | |
| if command.empty? | |
| puts 'Error: Command not specified.' | |
| puts "Usage: `ruby #{File.basename __FILE__} options -- command`" | |
| exit | |
| end |
In programming languages, literals are textual representations of values in the source code. This is a syntactical concept.
Some examples:
7 # integer literal| UI-OSF-USLP 共同技術資料 日本語EUCの定義と解説 | |
| 日本語 EUC の定義 | |
| require 'pty' | |
| require 'io/console' | |
| if ARGV.empty? | |
| puts <<~EOS | |
| Reline Visualizer (Minimal terminal emulator that only supports Reline's escape sequences) | |
| Usage: ruby #{__FILE__} <command>' | |
| ruby #{__FILE__} irb | |
| ruby #{__FILE__} bash | |
| ruby #{__FILE__} zsh | |
| ruby #{__FILE__} ruby -I path/to/reline/lib -I path/to/irb/lib path/to/irb/exe/irb |
| class << ($colored_stdout = STDOUT.dup) | |
| # Flip this if you are using bright theme | |
| BACKGROUND = [0, 0, 0] | |
| FOREGROUND = [255, 255, 255] | |
| RANDOMIZE_RANGE = -32..32 | |
| def rand_color(rgb, bg: false) | |
| "#{bg ? 48 : 38};2;#{rgb.map { (_1 + rand(RANDOMIZE_RANGE)).clamp(0, 0xff) }.join(';')}" | |
| end |
| class TemrinationChecker | |
| def initialize | |
| @prelaunched = nil | |
| @code = '' | |
| @current = new_session | |
| end | |
| def new_session | |
| IO.popen(['ruby', '-c'], 'r+', err: [:child, :out]) | |
| end |
| require 'io/console' | |
| num_status_lines = 4 | |
| $SYMBOLS = Symbol.all_symbols | |
| def status | |
| bold = "\e[1m" | |
| red = "\e[31m" | |
| green = "\e[32m" | |
| reset = "\e[m" | |
| [ |
この記事は、『研鑽Rubyプログラミング ― 実践的なコードのための原則とトレードオフ』 の感想記事です。レビューアーとして参加し、本書が広く読まれて欲しいので宣伝のために書きました。本記事は、"研鑽Rubyプログラミング β版 final"をもとに実施してます。なお、私自身はレビュアー参加のお礼として一冊本書をいただくことになっています。
私は2019年のRubyKaigiで、著者のJeremy EvansのKeynoteのレポート Jeremy Evansさん「たのしいRubyの先に、はやいRubyがある。Work, Correct, Fun! Fast」 〜RubyKaigi 2019 3日目 基調講演 を書いたことや、ある程度Ruby on Railsやデータベースに関するバックグラウンドがあったことから、その後翻訳者の角谷さんのレビューアー募集に応募して選ばれたというのがきっかけです。