Class: Fable::ListDefinitionsOrigin

Inherits:
Object
  • Object
show all
Defined in:
lib/fable/list_definitions_origin.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(lists) ⇒ ListDefinitionsOrigin

Returns a new instance of ListDefinitionsOrigin.



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/fable/list_definitions_origin.rb', line 13

def initialize(lists)
  self._lists = {}
  self.all_unambiguous_list_value_cache = {}

  lists.each do |list|
    self._lists[list.name] = list

    list.items.each do |item, int_value|
      list_value = ListValue.new(item, int_value)

      # May be ambiguous, but compiler should've caught that,
      # so we may be doing some replacement here, but that's okay
      self.all_unambiguous_list_value_cache[item.item_name] = list_value
      self.all_unambiguous_list_value_cache[item.full_name] = list_value
    end
  end
end

Instance Attribute Details

#_listsObject

Returns the value of attribute _lists.



3
4
5
# File 'lib/fable/list_definitions_origin.rb', line 3

def _lists
  @_lists
end

#all_unambiguous_list_value_cacheObject

Returns the value of attribute all_unambiguous_list_value_cache.



3
4
5
# File 'lib/fable/list_definitions_origin.rb', line 3

def all_unambiguous_list_value_cache
  @all_unambiguous_list_value_cache
end

Instance Method Details

#find_list(name) ⇒ Object



9
10
11
# File 'lib/fable/list_definitions_origin.rb', line 9

def find_list(name)
  self._lists[name]
end

#find_single_item_list_with_name(name) ⇒ Object



31
32
33
# File 'lib/fable/list_definitions_origin.rb', line 31

def find_single_item_list_with_name(name)
  return all_unambiguous_list_value_cache[name]
end

#listsObject



5
6
7
# File 'lib/fable/list_definitions_origin.rb', line 5

def lists
  self._lists.map{|k,v| v}
end