Class: Zakuro::Gateway::Range

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

Overview

Range 範囲

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(context:, range:) ⇒ Range

初期化

Parameters:

  • context (Context::Context)

    暦コンテキスト

  • range (Hash<Symbol, Object>)

    範囲



29
30
31
32
# File 'lib/zakuro/gateway/range.rb', line 29

def initialize(context:, range:)
  @context = context
  @range = Locale::Range.new(range: range)
end

Instance Attribute Details

#contextContext::Context (readonly)

Returns 暦コンテキスト.

Returns:



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

def context
  @context
end

#rangeLocale::Range (readonly)

Returns 範囲.

Returns:



21
22
23
# File 'lib/zakuro/gateway/range.rb', line 21

def range
  @range
end

Instance Method Details

#getResult::Range

検索結果を取得する

Returns:



49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
# File 'lib/zakuro/gateway/range.rb', line 49

def get
  start_date = range.start_date
  last_date = range.last_date

  return western(start_date: start_date, last_date: last_date) if range.valid_western?

  return japan(start_date: start_date, last_date: last_date) if range.valid_japan?

  raise Exception.get(
    presets: [
      Exception::Case::Preset.new(
        template: Exception::Case::Pattern::INVALID_RANGE
      )
    ]
  )
end

#invalid?True, False

不正か

Returns:

  • (True)

    不正

  • (False)

    不正なし



40
41
42
# File 'lib/zakuro/gateway/range.rb', line 40

def invalid?
  range.invalid?
end