Class: DMMCrawler::Attributes
- Inherits:
-
Object
- Object
- DMMCrawler::Attributes
- Defined in:
- lib/dmm-crawler/attributes.rb
Constant Summary collapse
- HTTP_STATUS_CODE_OF_SUCCESS =
200
Instance Method Summary collapse
- #affiliateable? ⇒ Boolean
-
#initialize(url, agent: Agent.instance.agent) ⇒ Attributes
constructor
A new instance of Attributes.
- #to_a ⇒ Object
Constructor Details
#initialize(url, agent: Agent.instance.agent) ⇒ Attributes
5 6 7 8 |
# File 'lib/dmm-crawler/attributes.rb', line 5 def initialize(url, agent: Agent.instance.agent) @page = agent.get(url) @r_client = Rdmm::Client.new(affiliate_id: ENV['DMM_AFFILIATE_ID'], api_id: ENV['DMM_API_ID']) end |
Instance Method Details
#affiliateable? ⇒ Boolean
24 25 26 |
# File 'lib/dmm-crawler/attributes.rb', line 24 def affiliateable? @r_client.list_items(site: 'DMM.R18', keyword: title).body['result']['status'] == HTTP_STATUS_CODE_OF_SUCCESS end |
#to_a ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/dmm-crawler/attributes.rb', line 10 def to_a [ title, title_link, image_url, submedia, , informations, price, affiliateable?, ] end |