Class: UserChoices::AbstractSource

Inherits:
Hash
  • Object
show all
Defined in:
lib/user-choices/sources.rb

Overview

TODO: Right now, elements that are named in a source, but not in an add_choice() call, nevertheless appear in the final array. Is that good? Bad? Irrelevant?

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeAbstractSource

Returns a new instance of AbstractSource.



20
21
22
23
# File 'lib/user-choices/sources.rb', line 20

def initialize
  super()
  @external_names = {}
end

Instance Attribute Details

#external_namesObject (readonly)

:nodoc:



18
19
20
# File 'lib/user-choices/sources.rb', line 18

def external_names
  @external_names
end

Instance Method Details

#adjust(final_results) ⇒ Object



42
43
44
# File 'lib/user-choices/sources.rb', line 42

def adjust(final_results)
  # Do nothing
end

#apply(choice_conversions) ⇒ Object



30
31
32
33
34
35
36
37
38
39
40
# File 'lib/user-choices/sources.rb', line 30

def apply(choice_conversions)
  each_conversion(choice_conversions) do | choice, conversion |
    next unless self.has_key?(choice)
    
    user_claims(conversion.suitable?(self[choice])) {
      error_prefix + bad_look(choice, conversion)
    }
    
    self[choice] = conversion.convert(self[choice])
  end
end

#each_conversion(choice_conversion_hash) ⇒ Object



46
47
48
49
50
51
52
# File 'lib/user-choices/sources.rb', line 46

def each_conversion(choice_conversion_hash)
  choice_conversion_hash.each do | choice, conversion_list | 
    conversion_list.each do | conversion |
      yield(choice, conversion)
    end
  end
end

#fillObject



28
# File 'lib/user-choices/sources.rb', line 28

def fill; subclass_responsibility; end

#sourceObject



25
# File 'lib/user-choices/sources.rb', line 25

def source; subclass_responsibility; end