Module: Cutter::Stamper::ClassMethods

Included in:
Cutter::Stamper
Defined in:
lib/cutter/stamper.rb

Instance Method Summary collapse

Instance Method Details

#[](key) ⇒ Object



164
165
166
# File 'lib/cutter/stamper.rb', line 164

def [] key
  stampers[key]
end

#lastObject



152
153
154
# File 'lib/cutter/stamper.rb', line 152

def last
  stamper_stack.last
end

#popObject



160
161
162
# File 'lib/cutter/stamper.rb', line 160

def pop
  stamper_stack.pop
end

#push(stamper) ⇒ Object



156
157
158
# File 'lib/cutter/stamper.rb', line 156

def push stamper
  stamper_stack.push stamper
end

#scope(label) {|stamper| ... } ⇒ Object

Yields:

Raises:

  • (ArgumentError)


142
143
144
145
146
147
148
149
150
# File 'lib/cutter/stamper.rb', line 142

def scope label, &block
  raise ArgumentError, "Must have hash, was: #{label}" if !label.kind_of? Hash
  raise ArgumentError, "Must have block" if !block
  stamper = Stamper.new(label)
  stampers[label.keys.first] = stamper
  yield stamper
  stamper_stack.pop
  stamper
end