Module: Cutter::Stamper::ClassMethods

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

Instance Method Summary collapse

Instance Method Details

#[](key) ⇒ Object



148
149
150
# File 'lib/cutter/stamper.rb', line 148

def [] key
  stampers[key]
end

#lastObject



136
137
138
# File 'lib/cutter/stamper.rb', line 136

def last
  stamper_stack.last
end

#popObject



144
145
146
# File 'lib/cutter/stamper.rb', line 144

def pop
  stamper_stack.pop
end

#push(stamper) ⇒ Object



140
141
142
# File 'lib/cutter/stamper.rb', line 140

def push stamper
  stamper_stack.push stamper
end

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

Yields:

Raises:

  • (ArgumentError)


126
127
128
129
130
131
132
133
134
# File 'lib/cutter/stamper.rb', line 126

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