class Figroll::Storage

A storage object for Figroll

Attributes

vars[R]

The known variables tracked by this storage instance @return [Hash<String, String>] @api private

Public Class Methods

new() click to toggle source

Create a new Storage instance @api private

# File lib/figroll/storage.rb, line 13
def initialize
  reset
end

Public Instance Methods

fetch(key) click to toggle source

Given a key, retrieve the value stored for that key. @param key [String, Symbol] the variable for which we want a value @return [String] the value of that variable @raise [RuntimeError] if the varible is not known @api private

# File lib/figroll/storage.rb, line 22
def fetch(key)
  @vars.fetch(Util.normalize(key))
end
import(incoming) click to toggle source

Given a hash of variables, import those variables into the instance. @params incoming [Hash<String, String>] @return nil @api private

# File lib/figroll/storage.rb, line 30
def import(incoming)
  incoming.keys.each do |key|
    vars[Util.normalize(key)] = incoming[key]
  end

  nil
end
keys() click to toggle source

Get the list of all stored variable names @return [Array<String>] @api private

# File lib/figroll/storage.rb, line 41
def keys
  vars.keys
end

Private Instance Methods

reset() click to toggle source
# File lib/figroll/storage.rb, line 46
def reset
  @vars = {}
end