Class: Fit4Ruby::GlobalFitDictList

Inherits:
Object
  • Object
show all
Defined in:
lib/fit4ruby/GlobalFitDictList.rb

Instance Method Summary collapse

Constructor Details

#initialize(&block) ⇒ GlobalFitDictList

Returns a new instance of GlobalFitDictList.



42
43
44
45
46
# File 'lib/fit4ruby/GlobalFitDictList.rb', line 42

def initialize(&block)
  @current_dict = nil
  @dicts = {}
  instance_eval(&block) if block_given?
end

Instance Method Details

#[](name) ⇒ Object



62
63
64
# File 'lib/fit4ruby/GlobalFitDictList.rb', line 62

def [](name)
  @dicts[name]
end

#dict(name) ⇒ Object



48
49
50
51
52
53
# File 'lib/fit4ruby/GlobalFitDictList.rb', line 48

def dict(name)
  if @dicts.include?(name)
    Log.fatal "Dictionary #{name} has already been defined"
  end
  @dicts[name] = @current_dict = GlobalFitDict.new
end

#entry(number, name) ⇒ Object



55
56
57
58
59
60
# File 'lib/fit4ruby/GlobalFitDictList.rb', line 55

def entry(number, name)
  unless @current_dict
    Log.fatal "You must define a dictionary first"
  end
  @current_dict.entry(number, name)
end