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.
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_string ⇒ Object (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
#build ⇒ Object
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 |