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.



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

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

Instance Method Details

#to_sObject



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

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

#unwrap(context: nil) ⇒ Object



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

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