Class: FifthedSim::StatBlock

Inherits:
Object
  • Object
show all
Defined in:
lib/fifthed_sim/stat_block.rb

Defined Under Namespace

Classes: DefinitionProxy

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(hash) ⇒ StatBlock

Returns a new instance of StatBlock.



41
42
43
44
45
46
47
48
49
# File 'lib/fifthed_sim/stat_block.rb', line 41

def initialize(hash)
  @hash = Hash[hash.map do |k, v|
    if v.is_a?(Stat)
      [k, v]
    else
      [k, Stat.new(v)]
    end
  end]
end

Class Method Details

.define(&block) ⇒ Object



36
37
38
39
# File 'lib/fifthed_sim/stat_block.rb', line 36

def self.define(&block)
  h = DefinitionProxy.new(&block)
  self.new(h.hash)
end