Class: Copypasta::Entry::Download

Inherits:
Base
  • Object
show all
Defined in:
lib/copypasta/entry/download.rb

Instance Attribute Summary collapse

Attributes inherited from Base

#filename

Instance Method Summary collapse

Methods inherited from Base

#apply

Constructor Details

#initialize(filename, source:, only_if: nil) ⇒ Download

Returns a new instance of Download.



10
11
12
13
14
15
16
17
18
19
# File 'lib/copypasta/entry/download.rb', line 10

def initialize(filename, source:, only_if: nil)
  raise "filename must be a string." unless filename.is_a?(String)
  raise "source url '#{source}' looks invalid." \
    unless source =~ URI::DEFAULT_PARSER.make_regexp
  raise "only_if must be null or a Proc." if !only_if.nil? && !only_if.is_a?(Proc)

  @filename = filename
  @source = source
  @only_if = only_if
end

Instance Attribute Details

#sourceObject (readonly)

Returns the value of attribute source.



8
9
10
# File 'lib/copypasta/entry/download.rb', line 8

def source
  @source
end