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.



54
55
56
# File 'lib/morfo/tools.rb', line 54

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.



52
53
54
# File 'lib/morfo/tools.rb', line 52

def input_string
  @input_string
end

Instance Method Details

#buildObject



58
59
60
61
62
63
64
# File 'lib/morfo/tools.rb', line 58

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

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