class SPF::Query::MacroString

Represents a string containing SPF macros.

Public Class Methods

new(elements) click to toggle source

Initializes the macro string.

@param [Array<String, Macro>] elements

String literals and String macros.
# File lib/spf/query/macro_string.rb, line 16
def initialize(elements)
  @elements = elements
end

Public Instance Methods

[](*arguments) click to toggle source

Accesses the String literal or macro at the given index or range.

@param [Integer, (Integer, Integer), Range] arguments

The index or range to access.

@return [Array<String, Macro>, String, Macro]

The String literal(s) or macro(s) at the given index or range.
# File lib/spf/query/macro_string.rb, line 43
def [](*arguments)
  @elements[*arguments]
end
each(&block) click to toggle source

Enumerates over the macro string literals and macros.

@yield [element]

@yieldparam [String, Macro] element

@return [Enumerator]

If no block is given, an Enumerator will be returned.
# File lib/spf/query/macro_string.rb, line 30
def each(&block)
  @elements.each(&block)
end
to_a() click to toggle source

Converts the macro string to an Array.

@return [Array<String, Macro>]

# File lib/spf/query/macro_string.rb, line 52
def to_a
  @elements
end
Also aliased as: to_ary
to_ary()
Alias for: to_a
to_s() click to toggle source

Converts the macro string to a String.

@return [String]

# File lib/spf/query/macro_string.rb, line 63
def to_s
  @elements.join
end