Class: Zakuro::Gateway::Single

Inherits:
Object
  • Object
show all
Defined in:
lib/zakuro/gateway/single.rb

Overview

Single 1日

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(context:, date:) ⇒ Single

初期化

Parameters:

  • context (Context::Context)

    暦コンテキスト

  • date (Date, String)

    日付



27
28
29
30
# File 'lib/zakuro/gateway/single.rb', line 27

def initialize(context:, date:)
  @context = context
  @date = Locale::Date.new(date: date)
end

Instance Attribute Details

#dateLocale::Date (readonly)

Returns 日付.

Returns:



19
20
21
# File 'lib/zakuro/gateway/single.rb', line 19

def date
  @date
end

Instance Method Details

#getResult::Single

検索結果を取得する

Returns:



47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
# File 'lib/zakuro/gateway/single.rb', line 47

def get
  if date.valid_western?
    return Calculation::Summary::Western::Single.get(
      context: @context, date: date.western_date
    )
  end

  if date.valid_japan?
    return Calculation::Summary::Japan::Single.get(
      context: @context, date: date.japan_date
    )
  end

  raise invalid_date_error
end

#invalid?True, False

不正か

Returns:

  • (True)

    不正

  • (False)

    不正なし



38
39
40
# File 'lib/zakuro/gateway/single.rb', line 38

def invalid?
  date.invalid?
end