Skip to content

Conversation

@jepe-w
Copy link
Owner

@jepe-w jepe-w commented Apr 26, 2024

No description provided.

Copy link

@JunichiIto JunichiIto left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

コメントしました!

…臭変数(item)の修正。トータル値をハッシュで管理するように改善

レビューにて指摘いただいた箇所の修正。個人的に気になった個所の改善
Copy link

@JunichiIto JunichiIto left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

コメントしました!

jepe-w added 2 commits May 8, 2024 17:16
配列filenameにつけた変数名を複数形へ修正。option_valuesの定義位置がおかしかったため移動。ifの条件を否定形ではなく、肯定形へ修正。ofを使用した変数名の修正。勘違いを誘発する変数名を修正。戻り値を使わないのにmapを使っていた箇所を修正
Copy link

@JunichiIto JunichiIto left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

途中までテキストでコメントしましたが、途中から動画に切り替えました。
動画レビューのURLは別途お知らせします〜。

jepe-w added 3 commits May 15, 2024 13:44
2人三脚ロジックを解消するために、hashを作るメソッド、標準入力か引数にファイル名を渡すかで違うメソッドを使うように修正。
一方の変数だけ変更し実行のほうを変えていなかった。しっかり最後まで実行確認していれば防げていたミス。
Copy link

@JunichiIto JunichiIto left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

今回も動画でレビューしたので別途リンクを送ります〜。

前回のレビューにて指摘を受けた、強引な処理や、へんてこなコードを自分なりに改善。
Copy link

@JunichiIto JunichiIto left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

今回も動画でレビューしたので別途リンクを送ります〜。
(1点、動画でコメントし忘れた内容をテキストで書いてます)

Copy link

@JunichiIto JunichiIto left a 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のデフォルト値を必ず重複しない値('')に修正。
Copy link

@JunichiIto JunichiIto left a 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へ修正。"
Copy link

@JunichiIto JunichiIto left a 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が返ってくる場合のみ要素をすべて反転するという処理に修正。
Copy link

@JunichiIto JunichiIto left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

数点コメントしましたが大きな問題ではないのでこれでOKです!🙆‍♂️

Comment on lines +43 to +45
options_count = options.count do |_key, value|
value == true
end

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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'] != ''

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
columns << file_detail['name'] if file_detail['name'] != ''
columns << file_detail['name'] unless file_detail['name'].empty?

と書くのもありです(英語っぽく読める)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants