Class: Proc

Inherits:
Object show all
Defined in:
lib/rmtools/core/b.rb,
lib/rmtools/core/proc.rb,
lib/rmtools/dev/highlight.rb

Constant Summary collapse

NULL =
lambda {|*x|}
TRUE =
lambda {|*x| true}
FALSE =
lambda {|*x| false}
SELF =
lambda {|x| x}

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#stringObject

Returns the value of attribute string.



7
8
9
# File 'lib/rmtools/core/proc.rb', line 7

def string
  @string
end

Class Method Details

.eval(string, binding = nil) ⇒ Object



18
19
20
21
# File 'lib/rmtools/core/proc.rb', line 18

def eval string, binding=nil
  (proc = (binding || Kernel).eval "proc {#{string}}").string = string
  proc
end

.falseObject



26
# File 'lib/rmtools/core/proc.rb', line 26

def false; FALSE end

.noopObject



24
# File 'lib/rmtools/core/proc.rb', line 24

def noop; NULL end

.selfObject



23
# File 'lib/rmtools/core/proc.rb', line 23

def self; SELF end

.trueObject



25
# File 'lib/rmtools/core/proc.rb', line 25

def true; TRUE end

Instance Method Details

#bObject



22
# File 'lib/rmtools/core/b.rb', line 22

def b; (self != NULL) && self end

#inspectObject



28
29
30
# File 'lib/rmtools/dev/highlight.rb', line 28

def inspect
  "#{to_s}#{@string ? ': '+Painter.green(@string) : source_location && ":\n"+RMTools.highlighted_line(*source_location)}"
end

#source_locationObject



30
# File 'lib/rmtools/core/proc.rb', line 30

def source_location; to_s.match(/([^@]+):(\d+)>$/)[1..2] end

#whenObject



9
10
11
12
13
14
# File 'lib/rmtools/core/proc.rb', line 9

def when
  Thread.new do
    sleep 0.001 until yield
    call
  end
end