Class: Morfo::Tools::BaseKeys
- Inherits:
-
Object
- Object
- Morfo::Tools::BaseKeys
- Defined in:
- lib/morfo/tools.rb
Instance Attribute Summary collapse
-
#input_string ⇒ Object
readonly
Returns the value of attribute input_string.
Instance Method Summary collapse
- #build ⇒ Object
-
#initialize(input_string) ⇒ BaseKeys
constructor
A new instance of BaseKeys.
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_string ⇒ Object (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
#build ⇒ Object
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 |