Skip to content

Commit 3543349

Browse files
committed
♻️ 正規表現定数名をREGEX_*プレフィックスパターンに変更
- TIMESTAMP_REGEX → REGEX_TIMESTAMP - YOUTUBE_ID_REGEX → REGEX_YOUTUBE_ID - コードの可読性を向上し、定数の命名規則を統一 - プレフィックスによる定数の種類の明確化
1 parent f383543 commit 3543349

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

app/controllers/podcasts_controller.rb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,10 +44,10 @@ def convert_shownote(content)
4444
HTML
4545
content.gsub!(/(#+) Shownote/) { shownote }
4646

47-
return content unless content.match?(Podcast::YOUTUBE_ID_REGEX)
48-
return content unless content.match?(Podcast::TIMESTAMP_REGEX)
49-
youtube_id = @episode.content.match(Podcast::YOUTUBE_ID_REGEX)[1]
50-
content.gsub!(Podcast::TIMESTAMP_REGEX) do
47+
return content unless content.match?(Podcast::REGEX_YOUTUBE_ID)
48+
return content unless content.match?(Podcast::REGEX_TIMESTAMP)
49+
youtube_id = @episode.content.match(Podcast::REGEX_YOUTUBE_ID)[1]
50+
content.gsub!(Podcast::REGEX_TIMESTAMP) do
5151
original_t = $1
5252
parts = original_t.split(':')
5353

app/models/podcast.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ class Podcast < ApplicationRecord
33
DIR_PATH = 'public/podcasts'
44
WDAY2JAPANESE = %w( )
55
# Match timestamps at the beginning of lines (YouTube format)
6-
TIMESTAMP_REGEX = /^((\d{1,2}:)?\d{1,2}:\d{2})/
7-
YOUTUBE_ID_REGEX = /watch\?v=((\w)*)/
6+
REGEX_TIMESTAMP = /^((\d{1,2}:)?\d{1,2}:\d{2})/
7+
REGEX_YOUTUBE_ID = /watch\?v=((\w)*)/
88

99
validates :title, presence: true
1010
validates :content_size, presence: true

0 commit comments

Comments
 (0)