Class: Morfo::Tools::BaseKeys

Inherits:
Object
  • Object
show all
Defined in:
lib/morfo/tools.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(input_string) ⇒ BaseKeys

Returns a new instance of BaseKeys.



37
38
39
# File 'lib/morfo/tools.rb', line 37

def initialize(input_string)
  @input_string = input_string.nil? ? "" : input_string.dup.freeze
end

Instance Attribute Details

#input_stringObject (readonly)

Returns the value of attribute input_string.



35
36
37
# File 'lib/morfo/tools.rb', line 35

def input_string
  @input_string
end

Instance Method Details

#buildObject



41
42
43
44
45
46
47
# File 'lib/morfo/tools.rb', line 41

def build
  keys = input_string.scan(/\%\{([^\}]+)\}/).flatten

  keys.inject({}) do |hash, key|
    hash.merge!(key.to_sym => nil)
  end
end