Class: Zakuro::Calculation::Summary::Month

Inherits:
Object
  • Object
show all
Defined in:
lib/zakuro/calculation/summary/internal/month.rb

Overview

Month 特定月

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(context:, start_date:, last_date:, year:, month:) ⇒ Month

初期化

Parameters:



38
39
40
41
42
43
44
# File 'lib/zakuro/calculation/summary/internal/month.rb', line 38

def initialize(context:, start_date:, last_date:, year:, month:)
  @context = context
  @start_date = start_date
  @last_date = last_date
  @year = year
  @month = month
end

Instance Attribute Details

#contextContext::Context (readonly)

Returns 暦コンテキスト.

Returns:



19
20
21
# File 'lib/zakuro/calculation/summary/internal/month.rb', line 19

def context
  @context
end

#last_dateWestern::Calendar (readonly)

Returns 西暦終了日.

Returns:



23
24
25
# File 'lib/zakuro/calculation/summary/internal/month.rb', line 23

def last_date
  @last_date
end

#monthMonthly::Month (readonly)

Returns 月.

Returns:



27
28
29
# File 'lib/zakuro/calculation/summary/internal/month.rb', line 27

def month
  @month
end

#start_dateWestern::Calendar (readonly)

Returns 西暦開始日.

Returns:



21
22
23
# File 'lib/zakuro/calculation/summary/internal/month.rb', line 21

def start_date
  @start_date
end

#yearBase::Year (readonly)

Returns 年.

Returns:



25
26
27
# File 'lib/zakuro/calculation/summary/internal/month.rb', line 25

def year
  @year
end

Instance Method Details

#getArray<Result::Data::SingleDay>

取得する

Returns:



51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
# File 'lib/zakuro/calculation/summary/internal/month.rb', line 51

def get
  result = []
  first_date = month.western_date.clone

  (0..month.days).each do |index|
    current_date = first_date.clone + index

    next unless include?(date: current_date)

    day = single_day(current_date: current_date)

    result.push(day)
  end

  result
end

#include?(date:) ⇒ True, False

含まれるか

Parameters:

Returns:

  • (True)

    含む

  • (False)

    含まない



76
77
78
79
80
81
82
# File 'lib/zakuro/calculation/summary/internal/month.rb', line 76

def include?(date:)
  return false if date < start_date

  return false if date > last_date

  true
end