Class: Chores
- Inherits:
-
Object
- Object
- Chores
- Defined in:
- lib/chores_kit/chores.rb
Instance Attribute Summary collapse
-
#chore ⇒ Object
readonly
Returns the value of attribute chore.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(filename) ⇒ Chores
constructor
A new instance of Chores.
- #run ⇒ Object
Constructor Details
#initialize(filename) ⇒ Chores
Returns a new instance of Chores.
10 11 12 |
# File 'lib/chores_kit/chores.rb', line 10 def initialize(filename) @chore = instance_eval(File.read(filename)) end |
Instance Attribute Details
#chore ⇒ Object (readonly)
Returns the value of attribute chore.
2 3 4 |
# File 'lib/chores_kit/chores.rb', line 2 def chore @chore end |
Class Method Details
.define(name, &block) ⇒ Object
4 5 6 7 8 |
# File 'lib/chores_kit/chores.rb', line 4 def self.define(name, &block) proxy = ChoresKit::DefinitionProxy.new(name) proxy.instance_eval(&block) if block_given? proxy.chore end |
.load(filename) ⇒ Object
14 15 16 |
# File 'lib/chores_kit/chores.rb', line 14 def self.load(filename) new(filename).chore end |
.load_all ⇒ Object
18 19 20 21 22 23 24 |
# File 'lib/chores_kit/chores.rb', line 18 def self.load_all tasks = Pathname.glob('tasks/**/*.rb') tasks.each do |task_file| load(Pathname.pwd + task_file) end end |
Instance Method Details
#run ⇒ Object
26 27 28 |
# File 'lib/chores_kit/chores.rb', line 26 def run @chore.run! end |