Class: ScriptRipper::Downloader

Inherits:
Object
  • Object
show all
Defined in:
lib/script_ripper/downloader.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(url) ⇒ Downloader

Returns a new instance of Downloader.



7
8
9
# File 'lib/script_ripper/downloader.rb', line 7

def initialize(url)
  @url = url
end

Instance Attribute Details

#urlObject (readonly)

Returns the value of attribute url.



5
6
7
# File 'lib/script_ripper/downloader.rb', line 5

def url
  @url
end

Class Method Details

.call(url) ⇒ Object



20
21
22
# File 'lib/script_ripper/downloader.rb', line 20

def call(url)
  new(url).call
end

Instance Method Details

#callObject



11
12
13
14
15
16
17
# File 'lib/script_ripper/downloader.rb', line 11

def call
  StringIO.new.tap { |content|
    URI.open(url) do |remote_content|
      content.write(remote_content.read)
    end
  }.string
end