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_raw_ribbon!Ribbon::Raw Also known as: extract_options_as_raw_ribbon!

Extracts the last argument as a raw ribbon or returns an empty one.

Returns:

  • (Ribbon::Raw)

    the raw ribbon at the end of this array

See Also:

Since:

  • 0.8.0



31
32
33
# File 'lib/ribbon/core_extensions/array.rb', line 31

def extract_raw_ribbon!
  Ribbon::Raw.new extract_ribbon!
end

#extract_ribbon!Ribbon Also known as: extract_options_as_ribbon!

Extracts the last argument as a ribbon or returns an empty one.

Returns:

  • (Ribbon)

    the ribbon at the end of this array

See Also:

  • #extract_raw_ribbon

Since:

  • 0.6.0



16
17
18
19
20
21
22
# File 'lib/ribbon/core_extensions/array.rb', line 16

def extract_ribbon!
  case last
    when Hash, Ribbon::Raw then Ribbon.new pop
    when Ribbon then pop
    else Ribbon.new
  end
end