Class: MkCalendar::Argument
- Inherits:
-
Object
- Object
- MkCalendar::Argument
- Defined in:
- lib/mk_calendar/argument.rb
Instance Method Summary collapse
-
#get_ymd ⇒ Object
引数取得.
-
#initialize(arg) ⇒ Argument
constructor
A new instance of Argument.
Constructor Details
#initialize(arg) ⇒ Argument
5 6 7 |
# File 'lib/mk_calendar/argument.rb', line 5 def initialize(arg) @date = arg end |
Instance Method Details
#get_ymd ⇒ Object
引数取得
-
コマンドライン引数を取得して日時の妥当性チェックを行う
-
コマンドライン引数無指定なら、現在日とする。
@return: jst (UNIX time)
17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/mk_calendar/argument.rb', line 17 def get_ymd unless @date =~ /^\d{8}$/ puts Const::USAGE return [] end year = @date[0,4].to_i month = @date[4,2].to_i day = @date[6,2].to_i unless Date.valid_date?(year, month, day) puts Const::MSG_ERR_1 return [] end return [year, month, day] end |