-
Notifications
You must be signed in to change notification settings - Fork 0
WCコマンド作成 #9
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
WCコマンド作成 #9
Conversation
JunichiIto
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
コメントしました!
…臭変数(item)の修正。トータル値をハッシュで管理するように改善 レビューにて指摘いただいた箇所の修正。個人的に気になった個所の改善
JunichiIto
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
コメントしました!
配列filenameにつけた変数名を複数形へ修正。option_valuesの定義位置がおかしかったため移動。ifの条件を否定形ではなく、肯定形へ修正。ofを使用した変数名の修正。勘違いを誘発する変数名を修正。戻り値を使わないのにmapを使っていた箇所を修正
JunichiIto
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
途中までテキストでコメントしましたが、途中から動画に切り替えました。
動画レビューのURLは別途お知らせします〜。
JunichiIto
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
今回も動画でレビューしたので別途リンクを送ります〜。
前回のレビューにて指摘を受けた、強引な処理や、へんてこなコードを自分なりに改善。
JunichiIto
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
今回も動画でレビューしたので別途リンクを送ります〜。
(1点、動画でコメントし忘れた内容をテキストで書いてます)
JunichiIto
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
コメントしました。
…handle_multiple_filesメソッド)の改善。total値の取得方法を改善。
もともとはoptionの値がすべて同じ場合はという条件だったが、より意図が伝わりやすいすべてfalseだった場合という方法へ改善。標準入力で受け取った値をいったん変数へ入れる冗長な手順を削除し、受け取った値をそのままjoinするように修正。total値の取得方法として、文字列をくっつけてその文字数等を取得するやり方をしていたが、このやり方では、場合によって思いがけない誤差が生まれる可能性があるため、値の合計値を取得するやり方に修正。failnameのデフォルト値を必ず重複しない値('')に修正。
JunichiIto
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
コメントしました!
メソッド名変更 create_words_width -> calc_column_width (l.55~) ifの条件で改行されているものを見やすくするために、(l.51)
で変数へいったん代入。 handle_multiple_filesメソッドにて、total[option.to_s]としていたto_sを削除。トータル値をsumで算出
に変更。l8 { |value| value == false }を!valueへ修正。"
JunichiIto
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
コメントしました!
calc_column_widthにて、文字数の最大値を求めるコードを、自然と一番大きくなるtotalのバイト数を取得する方法に変更。handle_multiple_filesメソッドのtotalを求めるコードを簡略化。optionの値について、values.none?でtrueが返ってくる場合のみ要素をすべて反転するという処理に修正。
JunichiIto
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
数点コメントしましたが大きな問題ではないのでこれでOKです!🙆♂️
| options_count = options.count do |_key, value| | ||
| value == true | ||
| end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| options_count = options.count do |_key, value| | |
| value == true | |
| end | |
| options_count = options.count { |_k, v| v } |
vが真のカウントを取得すればいいので、== true はなくせるのと、これぐらいなら1行で書いても問題ないと思います
| columns << file_detail['l'].to_s.rjust(width) if options['l'] | ||
| columns << file_detail['w'].to_s.rjust(width) if options['w'] | ||
| columns << file_detail['c'].to_s.rjust(width) if options['c'] | ||
| columns << file_detail['name'] if file_detail['name'] != '' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| columns << file_detail['name'] if file_detail['name'] != '' | |
| columns << file_detail['name'] unless file_detail['name'].empty? |
と書くのもありです(英語っぽく読める)
No description provided.