Class: Object

Inherits:
BasicObject
Defined in:
lib/lab42/tmux/extensions/object.rb,
lib/lab42/tmux/core_helpers.rb

Overview

Replace by lab42_core ASAP

Instance Method Summary collapse

Instance Method Details

#instance_eval_or_call(blk) ⇒ Object



3
4
5
6
7
8
9
# File 'lib/lab42/tmux/core_helpers.rb', line 3

def instance_eval_or_call blk
  if blk.arity.zero?
    instance_eval( &blk )
  else
    blk.( self )
  end
end

#with_present(attribute, &blk) ⇒ Object



4
5
6
7
8
9
# File 'lib/lab42/tmux/extensions/object.rb', line 4

def with_present attribute, &blk
  val = send attribute
  return nil unless val
  blk.( val )
rescue NoMethodError
end