Class: Coppertone::MacroString
- Inherits:
-
Object
- Object
- Coppertone::MacroString
show all
- Defined in:
- lib/coppertone/macro_string.rb,
lib/coppertone/macro_string/macro_expand.rb,
lib/coppertone/macro_string/macro_parser.rb,
lib/coppertone/macro_string/macro_literal.rb,
lib/coppertone/macro_string/macro_static_expand.rb
Overview
Instances of this class represent macro-strings, as defined by the SPF specification (see section 7.1).
MacroStrings should be evaluated (‘expanded’) in a particular context, as the MacroString may use of a number of values available from the context for interpolation.
Defined Under Namespace
Classes: MacroExpand, MacroLiteral, MacroParser, MacroStaticExpand
Instance Attribute Summary collapse
Instance Method Summary
collapse
Constructor Details
#initialize(macro_text) ⇒ MacroString
Returns a new instance of MacroString.
13
14
15
16
|
# File 'lib/coppertone/macro_string.rb', line 13
def initialize(macro_text)
@macro_text = macro_text
macros
end
|
Instance Attribute Details
#macro_text ⇒ Object
Returns the value of attribute macro_text.
11
12
13
|
# File 'lib/coppertone/macro_string.rb', line 11
def macro_text
@macro_text
end
|
Instance Method Details
#==(other) ⇒ Object
Also known as:
eql?
41
42
43
44
45
|
# File 'lib/coppertone/macro_string.rb', line 41
def ==(other)
return false unless other.instance_of? self.class
macro_text == other.macro_text
end
|
#context_dependent? ⇒ Boolean
#expand(context, request = nil) ⇒ Object
22
23
24
|
# File 'lib/coppertone/macro_string.rb', line 22
def expand(context, request = nil)
macros.map { |m| m.expand(context, request) }.join
end
|
#hash ⇒ Object
48
49
50
|
# File 'lib/coppertone/macro_string.rb', line 48
def hash
macro_text.hash
end
|
#includes_ptr? ⇒ Boolean
34
35
36
37
38
39
|
# File 'lib/coppertone/macro_string.rb', line 34
def includes_ptr?
expanded_macros = macros.select do |m|
m.is_a?(Coppertone::MacroString::MacroExpand)
end
expanded_macros.any?(&:ptr_macro?)
end
|
#macros ⇒ Object
18
19
20
|
# File 'lib/coppertone/macro_string.rb', line 18
def macros
@macros ||= MacroParser.new(macro_text).macros
end
|
#to_s ⇒ Object
26
27
28
|
# File 'lib/coppertone/macro_string.rb', line 26
def to_s
macros.map(&:to_s).join
end
|