Class: RubyWasm::Downloader
- Inherits:
-
Object
- Object
- RubyWasm::Downloader
- Defined in:
- lib/ruby_wasm/build/downloader.rb,
sig/ruby_wasm/build.rbs
Instance Method Summary collapse
Instance Method Details
#download(url, dest, message) ⇒ void
This method returns an undefined value.
3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
# File 'lib/ruby_wasm/build/downloader.rb', line 3 def download(url, dest, ) require "open-uri" content_length = 0 uri = URI.parse(url) OpenURI.open_uri( uri, content_length_proc: ->(len) { content_length = len }, progress_proc: ->(size) do print "\r#{} (#{SizeFormatter.format(content_length)}) %.2f%%" % (size.to_f / content_length * 100) end ) { |f| File.open(dest, "wb") { |out| out.write f.read } } puts "\r" end |
#format_size ⇒ String
338 |
# File 'sig/ruby_wasm/build.rbs', line 338
def format_size: (Integer size) -> String
|
#head ⇒ Boolean
341 |
# File 'sig/ruby_wasm/build.rbs', line 341
def head: (String url) -> bool
|