Class: Exerb::Recipe::GeneralBlock

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

Overview

#

Constant Summary collapse

KCODE =
['none', 'euc', 'sjis', 'utf8']

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(block, filename) ⇒ GeneralBlock

Returns a new instance of GeneralBlock

Raises:



170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
# File 'lib/exerb/recipe.rb', line 170

def initialize(block, filename)
  @startup = block.delete('startup') || ""
  @output  = block.delete('output')  || ""
  @core    = block.delete('core')    || ""
  @kcode   = block.delete('kcode')   || "none"

  @startup = nil if @startup.empty?
  @output  = nil if @output.empty?
  @core    = nil if @core.empty?
  @kcode.downcase!

  raise(Exerb::ExerbError, "#{filename}: unknown field at general block -- #{block.keys.join(', ')}") unless block.empty?
  raise(Exerb::ExerbError, "#{filename}: startup field isn't specified at general block") if @startup.nil?
  raise(Exerb::ExerbError, "#{filename}: unknown kcode at general block -- #{@kcode}") unless KCODE.include?(@kcode)
end

Instance Attribute Details

#coreObject (readonly)

Returns the value of attribute core



186
187
188
# File 'lib/exerb/recipe.rb', line 186

def core
  @core
end

#kcodeObject (readonly)

Returns the value of attribute kcode



186
187
188
# File 'lib/exerb/recipe.rb', line 186

def kcode
  @kcode
end

#outputObject (readonly)

Returns the value of attribute output



186
187
188
# File 'lib/exerb/recipe.rb', line 186

def output
  @output
end

#startupObject (readonly)

Returns the value of attribute startup



186
187
188
# File 'lib/exerb/recipe.rb', line 186

def startup
  @startup
end

Class Method Details

.analyze(blocks, filename) ⇒ Object

Raises:



188
189
190
191
192
193
# File 'lib/exerb/recipe.rb', line 188

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