Method: WrapIt::Sections::ClassMethods#place
- Defined in:
- lib/wrap_it/sections.rb
#place(src, to) ⇒ void #place(src, at, dst) ⇒ void
This method returns an undefined value.
Places specific section in specified place
150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 |
# File 'lib/wrap_it/sections.rb', line 150 def place(src, at, dst = nil) if dst == nil && at.is_a?(Hash) && at.keys.size == 1 dst = at.values[0] at = at.keys[0] end return unless placement.include?(src) && (dst == :begin || dst == :end || placement.include?(dst)) && (at == :before || at == :after) item = placement.delete_at(placement.index(src)) case dst when :begin then placement.unshift(item) when :end then placement.push(item) else x = at == :before ? 0 : 1 placement.insert(placement.index(dst) + x, item) end end |