class SPF::Mod
Public Class Methods
new(options = {})
click to toggle source
Calls superclass method
SPF::Term::new
# File lib/spf/model.rb, line 662 def initialize(options = {}) super @parse_text = options[:parse_text] @text = options[:text] @domain_spec = options[:domain_spec] @parse_text = @text.dup unless @parse_text if @domain_spec and not SPF::MacroString === @domain_spec @domain_spec = SPF::MacroString.new({:text => @domain_spec}) end end
Public Instance Methods
parse()
click to toggle source
# File lib/spf/model.rb, line 676 def parse error(SPF::NothingToParseError('Nothing to parse for modifier')) unless @parse_text self.parse_name if @errors.empty? self.parse_params(true) if @errors.empty? self.parse_end if @errors.empty? end
parse_end()
click to toggle source
# File lib/spf/model.rb, line 704 def parse_end unless @parse_text == '' error(SPF::JunkInTermError.new("Junk encountered in modifier #{@text}", @text, @parse_text)) end @parse_text = nil end
parse_name()
click to toggle source
# File lib/spf/model.rb, line 683 def parse_name @parse_text.sub!(/^(#{self.class::NAME})=/i, '') if $1 @name = $1 else error(SPF::InvalidModError.new( "Unexpected modifier name encoutered in #{@text}")) end end
parse_params(required = false)
click to toggle source
# File lib/spf/model.rb, line 693 def parse_params(required = false) # Parse generic macro string of parameters text (should be overridden in sub-classes): @parse_text.sub!(/^(#{MACRO_STRING_PATTERN})$/x, '') if $1 @params_text = $1 elsif required error(SPF::InvalidMacroStringError.new( "Invalid macro string encountered in #{@text}")) end end
to_s()
click to toggle source
# File lib/spf/model.rb, line 711 def to_s return sprintf( '%s=%s', @name, @params ? @params : '' ) end