Class: Tsumamigui::Request

Inherits:
Object
  • Object
show all
Defined in:
lib/tsumamigui/request.rb

Constant Summary collapse

INTERVAL =

sec

1.0..3.0

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(*urls) ⇒ Request

Returns a new instance of Request.

Parameters:

  • urls (String)
  • urls (Array<String>)

Raises:

  • (ArgumentError)


22
23
24
25
# File 'lib/tsumamigui/request.rb', line 22

def initialize(*urls)
  @urls = urls.flatten
  raise ArgumentError, 'No argument is specified' if @urls.empty?
end

Instance Attribute Details

#urlsObject (readonly)

Returns the value of attribute urls.



18
19
20
# File 'lib/tsumamigui/request.rb', line 18

def urls
  @urls
end

Class Method Details

.run(*urls) ⇒ Array<Tsumamigui::Response>

Returns response instances.

Parameters:

  • urls (String)
  • urls (Array<String>)

Returns:



11
12
13
# File 'lib/tsumamigui/request.rb', line 11

def run(*urls)
  new(urls).exec_request
end

Instance Method Details

#exec_requestArray<Tsumamigui::Response>

Execute request and return responses

Returns:



29
30
31
# File 'lib/tsumamigui/request.rb', line 29

def exec_request
  @urls.map { |url| fetch(url) }
end