Class: Chores

Inherits:
Object
  • Object
show all
Defined in:
lib/chores_kit/chores.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

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

#choreObject (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_allObject



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

#runObject



26
27
28
# File 'lib/chores_kit/chores.rb', line 26

def run
  @chore.run!
end