Class: RSAC::Lexeme
- Inherits:
-
Object
- Object
- RSAC::Lexeme
- Defined in:
- lib/antisamy/csspool/rsac/sac/lexeme.rb
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#pattern ⇒ Object
readonly
Returns the value of attribute pattern.
Instance Method Summary collapse
-
#initialize(name, pattern = nil) {|patterns| ... } ⇒ Lexeme
constructor
A new instance of Lexeme.
Constructor Details
#initialize(name, pattern = nil) {|patterns| ... } ⇒ Lexeme
Returns a new instance of Lexeme.
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/antisamy/csspool/rsac/sac/lexeme.rb', line 5 def initialize(name, pattern=nil, &block) raise ArgumentError, "name required" unless name @name = name patterns = [] patterns << pattern if pattern yield(patterns) if block_given? if patterns.empty? raise ArgumentError, "at least one pattern required" end patterns.collect! do |spattern| source = spattern.source source = "\\A#{source}" Regexp.new(source, Regexp::IGNORECASE + Regexp::MULTILINE, 'n') end @pattern = Regexp.union(*patterns) end |
Instance Attribute Details
#name ⇒ Object (readonly)
Returns the value of attribute name.
3 4 5 |
# File 'lib/antisamy/csspool/rsac/sac/lexeme.rb', line 3 def name @name end |
#pattern ⇒ Object (readonly)
Returns the value of attribute pattern.
3 4 5 |
# File 'lib/antisamy/csspool/rsac/sac/lexeme.rb', line 3 def pattern @pattern end |