Module: Ribbon::CoreExtensions::Array

Defined in:
lib/ribbon/core_extensions/array.rb

Overview

Methods to work with ribbons in arrays.

Author:

  • Matheus Afonso Martins Moreira

Since:

  • 0.6.0

Instance Method Summary collapse

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.

Returns:

  • (Ribbon)

    the Ribbon at the end of this array

Since:

  • 0.6.0



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.

Returns:

Since:

  • 0.6.0



29
30
31
# File 'lib/ribbon/core_extensions/array.rb', line 29

def extract_wrapped_ribbon!
  Ribbon.wrap extract_ribbon!
end