Class: Coppertone::Modifier
- Inherits:
-
Object
- Object
- Coppertone::Modifier
show all
- Defined in:
- lib/coppertone/modifier.rb,
lib/coppertone/modifier/exp.rb,
lib/coppertone/modifier/base.rb,
lib/coppertone/modifier/unknown.rb,
lib/coppertone/modifier/redirect.rb
Overview
Instances of this class represent modifier terms, as defined by the SPF specification (see section 4.6.1).
Defined Under Namespace
Classes: Base, Exp, Redirect, Unknown
Constant Summary
collapse
- MODIFIER_REGEXP =
/\A([a-zA-Z]+[a-zA-Z0-9\-\_\.]*)=(\S*)\z/
Instance Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
Constructor Details
#initialize(arguments) ⇒ Modifier
Returns a new instance of Modifier.
31
32
33
|
# File 'lib/coppertone/modifier.rb', line 31
def initialize(arguments)
@arguments = arguments
end
|
Instance Attribute Details
#arguments ⇒ Object
Returns the value of attribute arguments.
30
31
32
|
# File 'lib/coppertone/modifier.rb', line 30
def arguments
@arguments
end
|
Class Method Details
.build(type, attributes) ⇒ Object
9
10
11
|
# File 'lib/coppertone/modifier.rb', line 9
def self.build(type, attributes)
class_builder.build(type, attributes)
end
|
.build_unknown(type, attributes) ⇒ Object
26
27
28
|
# File 'lib/coppertone/modifier.rb', line 26
def self.build_unknown(type, attributes)
Coppertone::Modifier::Unknown.new(type, attributes)
end
|
.class_builder ⇒ Object
5
6
7
|
# File 'lib/coppertone/modifier.rb', line 5
def self.class_builder
@class_builder ||= ClassBuilder.new
end
|
.matching_term(text) ⇒ Object
18
19
20
21
22
23
24
|
# File 'lib/coppertone/modifier.rb', line 18
def self.matching_term(text)
matches = MODIFIER_REGEXP.match(text)
return nil unless matches
type = matches[1]
attributes = matches[2]
build(type, attributes) || build_unknown(type, attributes)
end
|
.register(klass) ⇒ Object
13
14
15
|
# File 'lib/coppertone/modifier.rb', line 13
def self.register(klass)
class_builder.register(klass.label, klass)
end
|
Instance Method Details
#label ⇒ Object
35
36
37
|
# File 'lib/coppertone/modifier.rb', line 35
def label
self.class.label
end
|
#to_s ⇒ Object
39
40
41
|
# File 'lib/coppertone/modifier.rb', line 39
def to_s
"#{label}=#{arguments}"
end
|