class PathRules::DateInfix
日付によるprefix, suffix, infixなどを表現するためのクラス¶ ↑
Constants
- OUTPUT_FORMAT
各種メソッドで日付を表現する時のフォーマット
Public Class Methods
new(date)
click to toggle source
@param date [String] infixとして使いたい日付。‘YYYY-MM-DD’形式。
# File lib/path_rules.rb, line 31 def initialize(date) check_argument_format!(date) @date = Date.strptime(date, '%Y-%m-%d') end
Public Instance Methods
beginning_of_month()
click to toggle source
@return [String] initializeに使った日付の月初日。
# File lib/path_rules.rb, line 42 def beginning_of_month @date.beginning_of_month.strftime(OUTPUT_FORMAT) end
to_s()
click to toggle source
# File lib/path_rules.rb, line 37 def to_s @date.strftime(OUTPUT_FORMAT) end
Private Instance Methods
check_argument_format!(date)
click to toggle source
@param date [String] initializeの引数となった文字列。
# File lib/path_rules.rb, line 49 def check_argument_format!(date) unless date =~ /\d{4}-\d{2}-\d{2}/ raise ArgumentError.new('引数はYYYY-MM-DD形式の文字列で与えてください。') end end