Class: Copypasta::Entry::Copy

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

Instance Attribute Summary collapse

Attributes inherited from Base

#filename

Instance Method Summary collapse

Methods inherited from Base

#apply

Constructor Details

#initialize(filename, directory:, source: nil, only_if: nil) ⇒ Copy

Returns a new instance of Copy.



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

def initialize(filename, directory:, source: nil, only_if: nil)
  raise "filename must be a string." unless filename.is_a?(String)
  raise "only_if must be null or a Proc." if !only_if.nil? && !only_if.is_a?(Proc)

  @filename = filename
  @directory = directory
  @only_if = only_if

  @source = source || filename
end

Instance Attribute Details

#sourceObject (readonly)

Returns the value of attribute source.



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

def source
  @source
end