Class: Wrapper

Inherits:
Object
  • Object
show all
Defined in:
lib/nrser/rspex.rb

Instance Method Summary collapse

Constructor Details

#initialize(description: nil, &block) ⇒ Wrapper

Returns a new instance of Wrapper.



52
53
54
55
# File 'lib/nrser/rspex.rb', line 52

def initialize description: nil, &block
  @description = description
  @block = block
end

Instance Method Details

#to_sObject



65
66
67
68
69
70
71
# File 'lib/nrser/rspex.rb', line 65

def to_s
  if @description
    @description.to_s
  else
    "#<Wrapper ?>"
  end
end

#unwrap(context: nil) ⇒ Object



57
58
59
60
61
62
63
# File 'lib/nrser/rspex.rb', line 57

def unwrap context: nil
  if context
    context.instance_exec &@block
  else
    @block.call
  end
end