Module: Yoga::Utils Private

Defined in:
lib/yoga/utils.rb

Overview

This module is part of a private API. You should avoid using this module if possible, as it may be removed or be changed in the future.

Utilities used with the Yoga module.

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.flatten_into_array(tokens) ⇒ <Yoga::Token>

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Takes an array of tokens or a set/array of tokens and turns it into a single array.


27
28
29
30
31
32
33
34
35
# File 'lib/yoga/utils.rb', line 27

def flatten_into_array(tokens)
  tokens.flat_map do |part|
    if part.is_a?(::Enumerable)
      flatten_into_array(part)
    else
      part
    end
  end
end

.flatten_into_set(tokens) ⇒ ::Set<Yoga::Token>

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Takes an array of tokens or set/array of tokens and turns it into a single set.


17
18
19
# File 'lib/yoga/utils.rb', line 17

def flatten_into_set(tokens)
  flatten_into_array(tokens).to_set
end

Instance Method Details

#flatten_into_array(tokens) ⇒ <Yoga::Token> (private)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Takes an array of tokens or a set/array of tokens and turns it into a single array.


27
28
29
30
31
32
33
34
35
# File 'lib/yoga/utils.rb', line 27

def flatten_into_array(tokens)
  tokens.flat_map do |part|
    if part.is_a?(::Enumerable)
      flatten_into_array(part)
    else
      part
    end
  end
end

#flatten_into_set(tokens) ⇒ ::Set<Yoga::Token> (private)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Takes an array of tokens or set/array of tokens and turns it into a single set.


17
18
19
# File 'lib/yoga/utils.rb', line 17

def flatten_into_set(tokens)
  flatten_into_array(tokens).to_set
end