Class: Exerb::Recipe::FileBlock

Inherits:
Object
  • Object
show all
Includes:
Enumerable
Defined in:
lib/exerb/recipe.rb

Overview

#

Defined Under Namespace

Classes: FileEntry

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(block, filename) ⇒ FileBlock

Returns a new instance of FileBlock.



334
335
336
337
338
339
340
# File 'lib/exerb/recipe.rb', line 334

def initialize(block, filename)
  @file = {}

  block.each { |internal_name, options|
    @file[internal_name] = FileEntry.new(internal_name, options, filename)
  }
end

Class Method Details

.analyze(blocks, filename) ⇒ Object

Raises:



342
343
344
345
346
347
# File 'lib/exerb/recipe.rb', line 342

def self.analyze(blocks, filename)
  block = blocks.delete("file")
  raise(Exerb::ExerbError, "#{filename}: file block not found") if block.nil?
  raise(Exerb::ExerbError, "#{filename}: file block must be Hash object -- #{block.class}") unless block.kind_of?(Hash)
  return self.new(block, filename)
end

Instance Method Details

#[](key) ⇒ Object



349
350
351
# File 'lib/exerb/recipe.rb', line 349

def [](key)
  return @file[key]
end

#delete(key) ⇒ Object



361
362
363
# File 'lib/exerb/recipe.rb', line 361

def delete(key)
  return @file.delete(key)
end

#each(&block) ⇒ Object



353
354
355
# File 'lib/exerb/recipe.rb', line 353

def each(&block)
  return @file.each(&block)
end

#keysObject



357
358
359
# File 'lib/exerb/recipe.rb', line 357

def keys
  return @file.keys
end