Top Level Namespace

Defined Under Namespace

Modules: HotOrNot Classes: Hash

Instance Method Summary collapse

Instance Method Details

#constantize(camel_cased_word) ⇒ Object



7
8
9
10
11
12
13
14
15
16
# File 'bin/hot_or_not', line 7

def constantize(camel_cased_word)
  names = camel_cased_word.split('::')
  names.shift if names.empty? || names.first.empty?

  constant = Object
  names.each do |name|
    constant = constant.const_defined?(name) ? constant.const_get(name) : constant.const_missing(name)
  end
  constant
end

#get_announcer(announcer) ⇒ Object



18
19
20
21
22
23
24
25
26
27
# File 'bin/hot_or_not', line 18

def get_announcer(announcer)
  klass = constantize(announcer) rescue nil
  return klass unless klass.nil?
  begin
    constantize("HotOrNot::#{announcer}Announcer")
  rescue NameError
    puts "Announcer #{announcer} cannot be found"
    exit 1
  end
end