class KeywordReplacer::Core
Constants
- ALLOWED_TYPES
Public Class Methods
new(options = {})
click to toggle source
# File lib/keyword_replacer/core.rb, line 7 def initialize(options = {}) include InstanceMethods define_method options[:method_name] do source = public_send(options[:source]) raise KeywordReplacer::TypeError unless ALLOWED_TYPES.include?(source.class.name) @options = Hash.new(0) @removed_links = {} @custom_class = options[:custom_class] @max_matches = options[:max_matches].call @keywords = options[:keywords].call @keywords_with_links = options[:keywords_with_links].call @keywords_matcher = Regexp.new('(' + keywords.join('|') + ')', Regexp::IGNORECASE) paste_links replace_keywords replace_links source.to_s end end