Module: Ripl::Rc::Anchor

Includes:
U
Defined in:
lib/ripl/rc/anchor.rb

Defined Under Namespace

Modules: AnchorImp, Imp

Instance Method Summary collapse

Methods included from U

included

Methods included from SqueezeHistory::Imp

#squeeze_history

Methods included from StripBacktrace::Imp

#cwd, #home, #snip, #strip_backtrace

Methods included from Imp

#short_inspect

Methods included from Color::Imp

#black, #blue, #color, #colors, #cyan, #find_color, #green, #magenta, #red, #reset, #white, #yellow

Instance Method Details

#loop_eval(str) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/ripl/rc/anchor.rb', line 7

def loop_eval(str)
  case obj_or_binding = (config[:rc_anchor] ||= []).last
    when NilClass
      super

    when Binding
      @binding = obj_or_binding
      super

    else
      obj_or_binding.instance_eval(str, "(#{@name})", @line)
  end
end

if the object is the same, then we’re exiting from an anchor, so don’t print anything.



33
34
35
36
# File 'lib/ripl/rc/anchor.rb', line 33

def print_result result
  super unless result != nil &&
               result.object_id == Ripl.config[:rc_anchor_last].object_id
end

#promptObject



21
22
23
24
25
26
27
28
29
# File 'lib/ripl/rc/anchor.rb', line 21

def prompt
  if Ripl::Rc.const_defined?(:Color) && kind_of?(Ripl::Rc::Color) &&
     obj_or_binding = (config[:rc_anchor] ||= []).last

    super.sub(@name, format_result(obj_or_binding, @name))
  else
    super
  end
end