Module: Ribbon::CoreExtensions::Array
- Defined in:
- lib/ribbon/core_extensions/array.rb
Overview
Methods to work with ribbons in arrays.
Instance Method Summary collapse
-
#extract_ribbon! ⇒ Ribbon
(also: #extract_options_as_ribbon!)
If the last argument is a hash, removes and converts it to a ribbon, otherwise returns an empty ribbon.
-
#extract_wrapped_ribbon! ⇒ Ribbon::Wrapper
(also: #extract_options_as_wrapped_ribbon!)
Extracts the last argument as a wrapped ribbon, or returns an empty one.
Instance Method Details
#extract_ribbon! ⇒ Ribbon Also known as: extract_options_as_ribbon!
If the last argument is a hash, removes and converts it to a ribbon, otherwise returns an empty ribbon.
16 17 18 19 20 21 22 23 |
# File 'lib/ribbon/core_extensions/array.rb', line 16 def extract_ribbon! case last when Hash then Ribbon.new pop when Ribbon then pop when Ribbon::Wrapper then pop.ribbon else Ribbon.new end end |
#extract_wrapped_ribbon! ⇒ Ribbon::Wrapper Also known as: extract_options_as_wrapped_ribbon!
Extracts the last argument as a wrapped ribbon, or returns an empty one. See #extract_ribbon! for details.
29 30 31 |
# File 'lib/ribbon/core_extensions/array.rb', line 29 def extract_wrapped_ribbon! Ribbon.wrap extract_ribbon! end |