Class: KenpoApi::ServiceGroup
- Inherits:
-
Object
- Object
- KenpoApi::ServiceGroup
- Defined in:
- lib/kenpo_api/service_group.rb
Instance Attribute Summary collapse
-
#category ⇒ Object
readonly
Returns the value of attribute category.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#path ⇒ Object
readonly
Returns the value of attribute path.
Class Method Summary collapse
Instance Method Summary collapse
- #available? ⇒ Boolean
- #find_service(name) ⇒ Object
-
#initialize(category:, name:, path:) ⇒ ServiceGroup
constructor
A new instance of ServiceGroup.
- #services ⇒ Object
Constructor Details
#initialize(category:, name:, path:) ⇒ ServiceGroup
Returns a new instance of ServiceGroup.
5 6 7 8 9 |
# File 'lib/kenpo_api/service_group.rb', line 5 def initialize(category:, name:, path:) @category = category @name = name @path = path end |
Instance Attribute Details
#category ⇒ Object (readonly)
Returns the value of attribute category.
3 4 5 |
# File 'lib/kenpo_api/service_group.rb', line 3 def category @category end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
3 4 5 |
# File 'lib/kenpo_api/service_group.rb', line 3 def name @name end |
#path ⇒ Object (readonly)
Returns the value of attribute path.
3 4 5 |
# File 'lib/kenpo_api/service_group.rb', line 3 def path @path end |
Class Method Details
.find(service_category, name) ⇒ Object
22 23 24 |
# File 'lib/kenpo_api/service_group.rb', line 22 def self.find(service_category, name) self.list(service_category).find { |group| group.name == name } end |
.list(service_category) ⇒ Object
11 12 13 14 15 16 17 18 19 20 |
# File 'lib/kenpo_api/service_group.rb', line 11 def self.list(service_category) return [] if service_category.nil? Client.instance.fetch_document(path: service_category.path).xpath('//section[@class="request-box"]//a').map do |link| self.new( category: service_category, name: link.text, path: link['href'], ) end end |