Class: OAK::KeyChain

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(keys) ⇒ KeyChain

Returns a new instance of KeyChain.



102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
# File 'lib/oak.rb', line 102

def initialize(keys)
  if !keys.is_a?(Hash)
    raise ArgumentError, "bogus keys #{keys}"
  end
  keys.each do |k,v|
    if !k.is_a?(String)
      raise ArgumentError, "bogus key #{k} in keys #{keys}"
    end
    if /^[a-zA-Z][0-9a-zA-Z]*$/ !~ k
      #
      # In oak_4, we restrict key names to sequences which look
      # like code identifiers: alphanumeric strings which start
      # with a letter.
      #
      # This keeps the encoding simple but compact.
      #
      raise ArgumentError, "bad key #{k} in keys #{keys}"
    end
    if !v.is_a?(Key)
      raise ArgumentError, "bogus val #{v} at #{k} in keys #{keys}"
    end
  end
  #
  # We are a happy KeyChain object now!
  #
  @keys = keys.dup.freeze
end

Instance Attribute Details

#keysObject (readonly)

Returns the value of attribute keys.



130
131
132
# File 'lib/oak.rb', line 130

def keys
  @keys
end