Class: HimekuriClass

Inherits:
Object show all
Defined in:
lib/himekuri.rb

Instance Method Summary collapse

Instance Method Details

#countObject



96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
# File 'lib/himekuri.rb', line 96

def count
  t = Time.new
  x = Time.mktime(t.year, t.month, t.day)
  y = Time.mktime(t.year + 1, 1, 1)

  # 1years 365 days.
  # 1years 365 days.
  if (((y - x) / 60 / 60 / 24) - 1).round.to_i.zero?
    '年の瀬、今年もお世話になりました。来年もよろしくお願いします!'
  elsif (((y - x) / 60 / 60 / 24) - 1).round.to_i == 1
    '元旦、新年明けましておめでとうございます!'
  else
    "来年の1月1日まであと: #{(((y - x) / 60 / 60 / 24) - 1).round} 日です"
  end
end

#count_printObject



18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/himekuri.rb', line 18

def count_print
  t = Time.new
  x = Time.mktime(t.year, t.month, t.day)
  y = Time.mktime(t.year + 1, 1, 1)

  # 1years 365 days.
  if (((y - x) / 60 / 60 / 24) - 1).round.to_i.zero?
    puts '年の瀬、今年もお世話になりました。来年もよろしくお願いします!'
  elsif (((y - x) / 60 / 60 / 24) - 1).round.to_i == 1
    puts '元旦、新年明けましておめでとうございます!'
  else
    puts "来年の1月1日まであと: #{(((y - x) / 60 / 60 / 24) - 1).round} 日です"
  end
end

#helpObject



132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
# File 'lib/himekuri.rb', line 132

def help
  puts 'HELP'.center(60, '-')
  puts ''
  puts 'koyomi'
  puts ''
  HimekuriClass.new.himekuri_print
  HimekuriClass.new.count_print
  HimekuriClass.new.reiwa_print
  HimekuriClass.new.version
  HimekuriClass.new.wahugetsu_print
  puts ''
  puts 'koyomi -r'
  puts ''
  HimekuriClass.new.himekuri_print
  puts ''
  puts 'koyomi -k'
  puts ''
  HimekuriClass.new.count_print
  puts ''
  puts 'koyomi -c'
  puts ''
  HimekuriClass.new.reiwa_print
  puts ''
  puts 'koyomi -v'
  puts ''
  HimekuriClass.new.version
  puts ''
  puts 'koyomi -w'
  puts ''
  HimekuriClass.new.wahugetsu_print
  puts ''
  puts 'koyomi -z'
  puts ''
  puts Zella.formula
  puts ''
  puts 'koyomi -z 2024 4 11'
  puts ''
  puts '2024年4月11日 : 木曜日'
  puts ''
  puts 'HELP'.center(60, '-')
end

#himekuriObject



89
90
91
92
93
94
# File 'lib/himekuri.rb', line 89

def himekuri
  dt = Date.today
  week = %w[      ][dt.wday]
  t = Time.new # 今日の日付と時刻
  "#{t.strftime('%Y年%m月%d日 : %H時%M分%S秒 : ')}#{week}曜日"
end

#himekuri_printObject



9
10
11
12
13
14
15
16
# File 'lib/himekuri.rb', line 9

def himekuri_print
  dt = Date.today
  week = %w[      ][dt.wday]
  print '時刻を表示 : '
  t = Time.new # 今日の日付と時刻
  print t.strftime('%Y年%m月%d日 : %H時%M分%S秒 : ')
  puts "#{week}曜日"
end

#reiwaObject



74
75
76
77
78
79
80
81
82
83
84
85
86
87
# File 'lib/himekuri.rb', line 74

def reiwa
  td = Date.today
  # nen = %w(平成 令和)
  # 2019/5/1以降
  # if ("#{td.year}".to_s+"#{td.month}".to_s).match?(/^20201$/)
  #  (nen[1] + "#{(td.year - 2018)}年"+"#{td.month}月"+"#{td.day}日")
  # else
  #  (nen[1] + "#{(td.year - 2018)}年".gsub(/[1]/,"元")+"#{td.month}月"+"#{td.day}日")
  # end

  # 2020/1/1以降
  nen = %w[令和]
  "#{nen[0]}#{td.year - 2018}#{td.month}#{td.day}#{%w[      ][td.wday]}曜日"
end

#reiwa_printObject



33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
# File 'lib/himekuri.rb', line 33

def reiwa_print
  # ------------------------------

  # ------------------------------
  t = Time.new # 今日の日付と時刻
  td = Date.today

  # 令和2年目以降
  nen = %w[令和]

  # 平成から令和の始まり
  # nen = ['平成', '令和']
  # ------------------------------

  # 2019/5/1以降
  # if ("#{td.year}".to_s+"#{td.month}".to_s).match?(/^20201$/)
  # if "#{td.year}" + "#{td.month}" =~ /^20201$/
  #  puts (nen[1] + "#{(td.year - 2018)}年"+"#{td.month}月"+"#{td.day}日") +" "+t.to_date.jisx0301
  # else
  #  puts (nen[1] + "#{(td.year - 2018)}年".gsub(/[1]/,"元")+"#{td.month}月"+"#{td.day}日") +" "+t.to_date.jisx0301
  # end

  # 2020/1/1以降
  puts "#{nen[0] + "#{td.year - 2018}" + "#{td.month}" + "#{td.day}"} : #{t.to_date.jisx0301}"
end

#versionObject



127
128
129
130
# File 'lib/himekuri.rb', line 127

def version
  print '日めくり数え番号 : '
  puts Himekuri::HIMEKURI_VERSION
end

#wahugetsu_printObject



59
60
61
62
63
64
65
66
67
68
69
70
71
72
# File 'lib/himekuri.rb', line 59

def wahugetsu_print
  td = Date.today
  nen = %w[令和]
  nen_y = %w[ 睦月 如月 弥生 卯月 皐月 水無月 文月 葉月 長月 神無月 霜月 師走][td.month]

  begin
    raise '「無」に辿り着いてはいけません!' if td.month.to_s.to_i.zero?


    puts("#{nen[0]}#{td.year - 2018}#{td.month}月 : #{nen_y}")
  rescue StandardError => e
    puts e.backtrace
  end
end

#wahugetsu_webObject



112
113
114
115
116
117
118
119
120
121
122
123
124
125
# File 'lib/himekuri.rb', line 112

def wahugetsu_web
  td = Date.today
  nen = %w[令和]
  nen_y = %w[ 睦月 如月 弥生 卯月 皐月 水無月 文月 葉月 長月 神無月 霜月 師走][td.month]

  begin
    raise '「無」に辿り着いてはいけません!' if td.month.to_s.to_i.zero?


    "#{nen[0]}#{td.year - 2018}#{td.month}月 : #{nen_y}"
  rescue StandardError => e
    e.backtrace
  end
end