In Files

Parent

Class/Module Index [+]

Quicksearch

Redwood::HookManager::HookContext

Public Class Methods

new(name) click to toggle source
# File lib/sup/hook.rb, line 5
def initialize name
  @__say_id = nil
  @__name = name
  @__cache = {}
end

Public Instance Methods

__run(__hook, __filename, __locals) click to toggle source
# File lib/sup/hook.rb, line 41
def __run __hook, __filename, __locals
  __binding = binding
  __lprocs, __lvars = __locals.partition { |k, v| v.is_a?(Proc) }
  eval __lvars.map { |k, v| "#{k} = __locals[#{k.inspect}];" }.join, __binding
  ## we also support closures for delays evaluation. unfortunately
  ## we have to do this via method calls, so you don't get all the
  ## semantics of a regular variable. not ideal.
  __lprocs.each do |k, v|
    self.class.instance_eval do
      define_method k do
        @__cache[k] ||= v.call
      end
    end
  end
  ret = eval __hook, __binding, __filename
  BufferManager.clear @__say_id if @__say_id
  @__cache = {}
  ret
end
ask_yes_or_no(q) click to toggle source
# File lib/sup/hook.rb, line 24
def ask_yes_or_no q
  if BufferManager.instantiated?
    BufferManager.ask_yes_or_no q
  else
    print q
    gets.chomp.downcase == 'y'
  end
end
get(tag) click to toggle source
# File lib/sup/hook.rb, line 33
def get tag
  HookManager.tags[tag]
end
log(s) click to toggle source
# File lib/sup/hook.rb, line 20
def log s
  info "hook[#@__name]: #{s}"
end
say(s) click to toggle source
# File lib/sup/hook.rb, line 11
def say s
  if BufferManager.instantiated?
    @__say_id = BufferManager.say s, @__say_id
    BufferManager.draw_screen
  else
    log s
  end
end
set(tag, value) click to toggle source
# File lib/sup/hook.rb, line 37
def set tag, value
  HookManager.tags[tag] = value
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.