Class: Fudge::Tasks::Task
- Inherits:
-
Object
- Object
- Fudge::Tasks::Task
- Defined in:
- lib/fudge/tasks/task.rb
Overview
Implementation of base Task
Direct Known Subclasses
Instance Attribute Summary collapse
-
#args ⇒ Object
readonly
Returns the value of attribute args.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
Class Method Summary collapse
-
.name ⇒ Symbol
Default name derived from class name.
Instance Method Summary collapse
-
#initialize(*args) ⇒ Task
constructor
A new instance of Task.
Constructor Details
#initialize(*args) ⇒ Task
Returns a new instance of Task.
17 18 19 20 21 22 23 24 25 26 |
# File 'lib/fudge/tasks/task.rb', line 17 def initialize(*args) @args = args.dup @options = @args[-1].kind_of?(Hash) ? @args.delete_at(-1) : {} @options.each do |k,v| send("#{k}=", v) if respond_to?("#{k}=") end @args end |
Instance Attribute Details
#args ⇒ Object (readonly)
Returns the value of attribute args.
5 6 7 |
# File 'lib/fudge/tasks/task.rb', line 5 def args @args end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
5 6 7 |
# File 'lib/fudge/tasks/task.rb', line 5 def @options end |
Class Method Details
.name ⇒ Symbol
Default name derived from class name. Can be overriden by specific tasks.
11 12 13 14 15 |
# File 'lib/fudge/tasks/task.rb', line 11 def self.name name = /(\w+::)*(?<class>\w+\z)/.match(super)[:class] underscored = name.gsub(/(?<pre>[^_])(?<char>[A-Z])/, "\\k<pre>_\\k<char>") underscored.downcase.to_sym end |