class Zakuro::Calculation::Monthly::MonthLabel

MonthLabel 月表示情報

Attributes

is_many_days[R]

@return [True] 大の月(30日) @return [False] 小の月(29日)

leaped[R]

@return [True] 閏月 @return [False] 平月

number[R]

@return [Integer] 月(xx月のxx)

Public Class Methods

new(number: -1, is_many_days: false, leaped: false) click to toggle source

初期化

@param [Integer] number 月(xx月のxx) @param [True, False] is_many_days 月の大小 @param [True, False] leaped 閏月/平月

# File lib/zakuro/calculation/monthly/month_label.rb, line 31
def initialize(number: -1, is_many_days: false, leaped: false)
  # 月の大小
  @is_many_days = is_many_days
  # 月
  @number = number
  # 閏
  @leaped = leaped
end

Public Instance Methods

back_to_last_month() click to toggle source

一ヶ月戻す

@return [True] 昨年 @return [False] 今年

# File lib/zakuro/calculation/monthly/month_label.rb, line 64
def back_to_last_month
  @number -= 1

  return false if @number.positive?

  @number = 12

  true
end
days() click to toggle source

月の日数を返す

@return [Integer] 日数

# File lib/zakuro/calculation/monthly/month_label.rb, line 45
def days
  @is_many_days ? 30 : 29
end
days_name() click to toggle source

月の名前(大小)を返す

@return [String] 月の名前(大小)

# File lib/zakuro/calculation/monthly/month_label.rb, line 54
def days_name
  @is_many_days ? '大' : '小'
end
same?(other:) click to toggle source

同一の月情報かを検証する

@param [Month] other 他の月情報

@return [True] 同一の月 @return [False] 異なる月

# File lib/zakuro/calculation/monthly/month_label.rb, line 82
def same?(other:)
  @number == other.number && @leaped == other.leaped
end