Class: Cloudrider::Protofile

Inherits:
Object
  • Object
show all
Defined in:
lib/cloudrider/protofile.rb

Defined Under Namespace

Classes: OnlyBeCalledWhenNoType

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(opts = {}) ⇒ Protofile

Returns a new instance of Protofile.



4
5
6
7
8
# File 'lib/cloudrider/protofile.rb', line 4

def initialize(opts={})
  @type = opts[:type]
  @source = opts[:source]
  @target = opts[:target]
end

Instance Attribute Details

#file_nameObject

Returns the value of attribute file_name.



3
4
5
# File 'lib/cloudrider/protofile.rb', line 3

def file_name
  @file_name
end

#folderObject

Returns the value of attribute folder.



3
4
5
# File 'lib/cloudrider/protofile.rb', line 3

def folder
  @folder
end

#rendererObject

Returns the value of attribute renderer.



3
4
5
# File 'lib/cloudrider/protofile.rb', line 3

def renderer
  @renderer
end

#sourceObject

Returns the value of attribute source.



3
4
5
# File 'lib/cloudrider/protofile.rb', line 3

def source
  @source
end

#targetObject

Returns the value of attribute target.



3
4
5
# File 'lib/cloudrider/protofile.rb', line 3

def target
  @target
end

#typeObject

Returns the value of attribute type.



3
4
5
# File 'lib/cloudrider/protofile.rb', line 3

def type
  @type
end

Instance Method Details

#contentObject



13
14
15
# File 'lib/cloudrider/protofile.rb', line 13

def content
  renderer.call
end

#full_nameObject



9
10
11
12
# File 'lib/cloudrider/protofile.rb', line 9

def full_name
  raise OnlyBeCalledWhenNoType, _debug_string if ["copy_file", "directory"].include? @type.to_s
  File.join *[folder, file_name].reject(&:blank?)
end