Skip to content

Instantly share code, notes, and snippets.

@ccoupe
Created September 15, 2015 05:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save ccoupe/95e095cbb749ba7c5006 to your computer and use it in GitHub Desktop.
Save ccoupe/95e095cbb749ba7c5006 to your computer and use it in GitHub Desktop.
find out what Shoes.APPS[] and app are.
# explore APPS and app (s)
# don't name anything as 'app' unless you enjoy confusion
class Shoes::Types::App
def myinspect(target, from)
puts "For #{target.name} (from #{app.name})"
#puts "app and from are same object: #{target === app}"
puts "instance vars"
puts "#{target.inspect}"
puts target.instance_variables
end
def mynew_ivar(target, name, value)
target.instance_variable_set(name,value)
end
def mybinding
target.binding()
end
end
Shoes.app title: "Home" do
$var_incr = 0
para "Be Confused"
window title: "Not_Home" do
stack do
button "info" do
para "#{Shoes.APPS.inspect}\n"
para "owner = #{owner}\n"
para "me = #{app.inspect}\n"
end
button "launch" do
$var_incr = $var_incr + 1
window title: "really not home #{$var_incr}" do
stack do
apps = Shoes.APPS
para "#{Shoes.APPS.inspect}\n"
para "owner = #{owner}\n"
para "me = #{app.inspect}\n"
stack do
apps.each do |item|
ivarstr = "@iv#{$var_incr+10}"
flow do
button "show #{item.name}" do
myinspect(item, app)
end
button "add @ivar" do
mynew_ivar(item, "@iv#{$var_incr+10}", "initial value")
end
button "create alert @ivar" do
cmd = "button \"show #{ivarstr}\" do alert \"\#\{#{ivarstr}\}\" end"
puts cmd
item.instance_eval(cmd)
end
end
end
end
end
end
end
end
end
stack do
para "#{Shoes.APPS.inspect}"
para "owner = #{owner}"
para "me = #{app.inspect}"
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment