Class: Dragonfly::Job::Step

Inherits:
Object show all
Defined in:
lib/dragonfly/job/step.rb

Direct Known Subclasses

Fetch, FetchFile, FetchUrl, Generate, Process

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(job, *args) ⇒ Step

Returns a new instance of Step



20
21
22
23
# File 'lib/dragonfly/job/step.rb', line 20

def initialize(job, *args)
  @job, @args = job, args
  init
end

Instance Attribute Details

#argsObject (readonly)

Returns the value of attribute args



28
29
30
# File 'lib/dragonfly/job/step.rb', line 28

def args
  @args
end

#jobObject (readonly)

Returns the value of attribute job



28
29
30
# File 'lib/dragonfly/job/step.rb', line 28

def job
  @job
end

Class Method Details

.abbreviationObject

Dragonfly::Job::Fetch -> 'f'



15
16
17
# File 'lib/dragonfly/job/step.rb', line 15

def abbreviation
  @abbreviation ||= basename.scan(/[A-Z]/).join.downcase
end

.basenameObject

Dragonfly::Job::Fetch -> 'Fetch'



7
8
9
# File 'lib/dragonfly/job/step.rb', line 7

def basename
  @basename ||= name.split('::').last
end

.step_nameObject

Dragonfly::Job::Fetch -> :fetch



11
12
13
# File 'lib/dragonfly/job/step.rb', line 11

def step_name
  @step_name ||= basename.gsub(/[A-Z]/){ "_#{$&.downcase}" }.sub('_','').to_sym
end

Instance Method Details

#appObject



30
31
32
# File 'lib/dragonfly/job/step.rb', line 30

def app
  job.app
end

#initObject

To be overridden



25
26
# File 'lib/dragonfly/job/step.rb', line 25

def init # To be overridden
end

#inspectObject



38
39
40
# File 'lib/dragonfly/job/step.rb', line 38

def inspect
  "#{self.class.step_name}(#{args.map{|a| a.inspect }.join(', ')})"
end

#to_aObject



34
35
36
# File 'lib/dragonfly/job/step.rb', line 34

def to_a
  [self.class.abbreviation, *args]
end