class EleetScript::MethodHash

Public Class Methods

new() click to toggle source
# File lib/lang/runtime/method_hash.rb, line 3
def initialize
  @instance_methods = {}
  @class_methods = {}
end

Public Instance Methods

[](key) click to toggle source
# File lib/lang/runtime/method_hash.rb, line 8
def [](key)
  store = fetch_method_store(key)
  key = clean_key(key)
  store[key]
end
[]=(key, value) click to toggle source
# File lib/lang/runtime/method_hash.rb, line 14
def []=(key, value)
  store = fetch_method_store(key)
  key = clean_key(key)
  store[key] = value
end
keys() click to toggle source
# File lib/lang/runtime/method_hash.rb, line 20
def keys
  keys = @class_methods.keys.map { |k| "@@#{k}" }
  keys += @instance_methods.keys
  keys
end

Private Instance Methods

clean_key(key) click to toggle source
# File lib/lang/runtime/method_hash.rb, line 28
def clean_key(key)
  key[0..1] == "@@" ? key[2..-1] : key
end
fetch_method_store(key) click to toggle source
# File lib/lang/runtime/method_hash.rb, line 32
def fetch_method_store(key)
  if key[0..1] == "@@"
    @class_methods
  else
    @instance_methods
  end
end