Class: KenpoApi::ServiceCategory

Inherits:
Object
  • Object
show all
Defined in:
lib/kenpo_api/service_category.rb

Constant Summary collapse

CATEGORIES =
{
  resort_reserve:       '直営・通年・夏季保養施設(抽選申込)',
  resort_search_vacant: '直営・通年・夏季保養施設(空き照会)',
  sport_reserve:        'スポーツ施設(抽選申込)',
  sport_search_vacant:  'スポーツ施設(空き照会)',
  resort_alliance:      '契約保養施設(補助金対象施設)',
  travel_pack:          'ITS旅行パック(補助申請)',
  golf_course:          'ITS契約ゴルフ場',
  camp_site:            'ITS契約オートキャンプ場',
  laforet:              'ラフォーレ倶楽部',
  thalassotherapy:      'タラソテラピー',
  recreation:           '体育奨励イベント',
  room_search_vacant:   '健保会館付属会議室(空き照会)',
}

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name:, path:) ⇒ ServiceCategory

Returns a new instance of ServiceCategory.



20
21
22
23
24
# File 'lib/kenpo_api/service_category.rb', line 20

def initialize(name:, path:)
  @category_code = CATEGORIES.key(name)
  @name = name
  @path = path
end

Instance Attribute Details

#category_codeObject (readonly)

Returns the value of attribute category_code.



18
19
20
# File 'lib/kenpo_api/service_category.rb', line 18

def category_code
  @category_code
end

#nameObject (readonly)

Returns the value of attribute name.



18
19
20
# File 'lib/kenpo_api/service_category.rb', line 18

def name
  @name
end

#pathObject (readonly)

Returns the value of attribute path.



18
19
20
# File 'lib/kenpo_api/service_category.rb', line 18

def path
  @path
end

Class Method Details

.find(category_code) ⇒ Object



35
36
37
# File 'lib/kenpo_api/service_category.rb', line 35

def self.find(category_code)
  self.list.find { |category| category.category_code == category_code }
end

.listObject



26
27
28
29
30
31
32
33
# File 'lib/kenpo_api/service_category.rb', line 26

def self.list
  Client.instance.fetch_document(path: '/service_category/index').xpath('//div[@class="request-box"]//a').map do |link|
    self.new(
      name: link.text,
      path: link['href'],
    )
  end
end

Instance Method Details

#available?Boolean

Returns:

  • (Boolean)


47
48
49
# File 'lib/kenpo_api/service_category.rb', line 47

def available?
  self.service_groups.any?
end

#find_service_group(name) ⇒ Object



43
44
45
# File 'lib/kenpo_api/service_category.rb', line 43

def find_service_group(name)
  ServiceGroup.find(self, name)
end

#service_groupsObject



39
40
41
# File 'lib/kenpo_api/service_category.rb', line 39

def service_groups
  ServiceGroup.list(self)
end