Module: ExploreRb
- Defined in:
- lib/explore_rb.rb,
lib/explore_rb/version.rb
Constant Summary collapse
- VERSION =
"1.1.0"
Class Method Summary collapse
Instance Method Summary collapse
- #classes ⇒ Object
- #draw_this(&block) ⇒ Object
- #gems ⇒ Object
- #get_objects(klass) ⇒ Object
- #load_paths ⇒ Object
- #objects ⇒ Object
- #start_garbage_collection ⇒ Object
- #stop_garbage_collection ⇒ Object
- #symbols ⇒ Object
Class Method Details
.extended(base) ⇒ Object
6 7 8 9 10 11 |
# File 'lib/explore_rb.rb', line 6 def self.extended base puts "Use the following commands to look around:" puts " classes, objects, get_objects, symbols, gems," puts " local_variables, draw_this, start_garbage_collection" puts " stop_garbage_collection, load_paths, help" end |
Instance Method Details
#classes ⇒ Object
13 14 15 |
# File 'lib/explore_rb.rb', line 13 def classes (Object.constants - [:RUBY_COPYRIGHT, :RUBY_DESCRIPTION, :RUBY_ENGINE, :RUBY_PATCHLEVEL, :RUBY_PLATFORM, :RUBY_RELEASE_DATE, :RUBY_REVISION, :RUBY_VERSION, :CROSS_COMPILING ]).sort end |
#draw_this(&block) ⇒ Object
39 40 41 42 43 |
# File 'lib/explore_rb.rb', line 39 def draw_this &block path = "#{ENV['HOME']}/Desktop" Traceur.watch_paths('.+', path, &block) puts "File saved in #{path}." end |
#gems ⇒ Object
33 34 35 36 37 |
# File 'lib/explore_rb.rb', line 33 def gems gems = {} Gem::Specification.each{|s| gems[s.name]= s.gem_dir.gsub(ENV['HOME'], "~") } gems end |
#get_objects(klass) ⇒ Object
23 24 25 26 27 |
# File 'lib/explore_rb.rb', line 23 def get_objects klass requested_klass = [] ObjectSpace.each_object{|o| requested_klass << ObjectSpace._id2ref(o.object_id) if o.class == klass} requested_klass end |
#load_paths ⇒ Object
55 56 57 58 59 |
# File 'lib/explore_rb.rb', line 55 def load_paths # $: returns a reference. # For demo purposes we want a value. Array.new $: end |
#objects ⇒ Object
17 18 19 20 21 |
# File 'lib/explore_rb.rb', line 17 def objects objects = Hash.new {0} ObjectSpace.each_object{|obj| objects[obj.class] += 1 } objects end |
#start_garbage_collection ⇒ Object
45 46 47 48 49 |
# File 'lib/explore_rb.rb', line 45 def start_garbage_collection ENV['RUBY_GC_MALLOC_LIMIT']='0' GC.stress=true GC.start end |
#stop_garbage_collection ⇒ Object
51 52 53 |
# File 'lib/explore_rb.rb', line 51 def stop_garbage_collection GC.stress=false end |
#symbols ⇒ Object
29 30 31 |
# File 'lib/explore_rb.rb', line 29 def symbols Symbol.all_symbols end |