Class: Exerb::Recipe::ResourceBlock

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

Overview

#

Defined Under Namespace

Classes: IconBlock, VersionBlock

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(block, filename) ⇒ ResourceBlock

Returns a new instance of ResourceBlock

Raises:


223
224
225
226
227
# File 'lib/exerb/recipe.rb', line 223

def initialize(block, filename)
  @icon    = IconBlock.analyze(block, filename)
  @version = VersionBlock.analyze(block, filename)
  raise(Exerb::ExerbError, "#{filename}: unknown field at resource block -- #{block.keys.join(', ')}") unless block.empty?
end

Instance Attribute Details

#iconObject (readonly)

Returns the value of attribute icon


229
230
231
# File 'lib/exerb/recipe.rb', line 229

def icon
  @icon
end

#versionObject (readonly)

Returns the value of attribute version


229
230
231
# File 'lib/exerb/recipe.rb', line 229

def version
  @version
end

Class Method Details

.analyze(blocks, filename) ⇒ Object

Raises:


231
232
233
234
235
236
# File 'lib/exerb/recipe.rb', line 231

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