Class: Whisk::WhiskFile
- Inherits:
-
Object
- Object
- Whisk::WhiskFile
- Defined in:
- lib/whisk/whiskfile.rb
Instance Attribute Summary collapse
-
#bowls ⇒ Object
Returns the value of attribute bowls.
Class Method Summary collapse
Instance Method Summary collapse
- #add_bowl(bowl) ⇒ Object
- #bowl(name, &block) ⇒ Object
-
#initialize ⇒ WhiskFile
constructor
A new instance of WhiskFile.
Constructor Details
#initialize ⇒ WhiskFile
Returns a new instance of WhiskFile.
32 33 34 |
# File 'lib/whisk/whiskfile.rb', line 32 def initialize @bowls = {} end |
Instance Attribute Details
#bowls ⇒ Object
Returns the value of attribute bowls.
30 31 32 |
# File 'lib/whisk/whiskfile.rb', line 30 def bowls @bowls end |
Class Method Details
.from_file(filename) ⇒ Object
51 52 53 54 55 56 57 58 59 |
# File 'lib/whisk/whiskfile.rb', line 51 def from_file(filename) if ::File.exists?(filename) && ::File.readable?(filename) whiskfile = Whisk::WhiskFile.new whiskfile.instance_eval(::IO.read(filename), filename, 1) whiskfile else raise IOError, "Cannot open or read #{filename}!" end end |
Instance Method Details
#add_bowl(bowl) ⇒ Object
36 37 38 39 40 41 42 |
# File 'lib/whisk/whiskfile.rb', line 36 def add_bowl(bowl) if bowls.has_key? bowl.name raise ArgumentError, "bowl #{bowl.name} already exists" else bowls[bowl.name] = bowl end end |