Class: Zakuro::Calculation::Monthly::MonthLabel

Inherits:
Object
  • Object
show all
Defined in:
lib/zakuro/calculation/monthly/internal/part/month_label.rb

Overview

MonthLabel 月表示情報

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(number: -1,, is_many_days: false, leaped: false) ⇒ MonthLabel

初期化

Parameters:

  • number (Integer) (defaults to: -1,)

    月(xx月のxx)

  • is_many_days (True, False) (defaults to: false)

    月の大小

  • leaped (True, False) (defaults to: false)

    閏月/平月



31
32
33
34
35
36
37
38
# File 'lib/zakuro/calculation/monthly/internal/part/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

Instance Attribute Details

#is_many_daysTrue, False (readonly)

Returns:

  • (True)

    大の月(30日)

  • (False)

    小の月(29日)



15
16
17
# File 'lib/zakuro/calculation/monthly/internal/part/month_label.rb', line 15

def is_many_days
  @is_many_days
end

#leapedTrue, False (readonly)

Returns:

  • (True)

    閏月

  • (False)

    平月



20
21
22
# File 'lib/zakuro/calculation/monthly/internal/part/month_label.rb', line 20

def leaped
  @leaped
end

#numberInteger (readonly)

Returns 月(xx月のxx).

Returns:

  • (Integer)

    月(xx月のxx)



17
18
19
# File 'lib/zakuro/calculation/monthly/internal/part/month_label.rb', line 17

def number
  @number
end

Instance Method Details

#back_to_last_monthTrue, False

一ヶ月戻す

Returns:

  • (True)

    昨年

  • (False)

    今年



64
65
66
67
68
69
70
71
72
# File 'lib/zakuro/calculation/monthly/internal/part/month_label.rb', line 64

def back_to_last_month
  @number -= 1

  return false if number.positive?

  @number = 12

  true
end

#daysInteger

月の日数を返す

Returns:

  • (Integer)

    日数



45
46
47
# File 'lib/zakuro/calculation/monthly/internal/part/month_label.rb', line 45

def days
  is_many_days ? 30 : 29
end

#days_nameString

月の名前(大小)を返す

Returns:

  • (String)

    月の名前(大小)



54
55
56
# File 'lib/zakuro/calculation/monthly/internal/part/month_label.rb', line 54

def days_name
  is_many_days ? '' : ''
end

#same?(other:) ⇒ True, False

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

Parameters:

  • other (Month)

    他の月情報

Returns:

  • (True)

    同一の月

  • (False)

    異なる月



82
83
84
# File 'lib/zakuro/calculation/monthly/internal/part/month_label.rb', line 82

def same?(other:)
  number == other.number && leaped == other.leaped
end