Sha256: b9b668115da20394fe3ba8b240e7681966682dd1c09430e356d5b887e5e012f5
Contents?: true
Size: 1.22 KB
Versions: 3
Compression:
Stored size: 1.22 KB
Contents
module Hashtags class Variable < Base def self.trigger '$' end def self.regexp /#{Regexp.escape(trigger)}(.+?)\b/i end def self.values(hashtag_classes = Variable.descendants) raise NotImplemented end def self.help_values values end # --------------------------------------------------------------------- # JS def self.match_regexp /(\A#{Regexp.escape(trigger)}|\s#{Regexp.escape(trigger)})(\w{1,})\z/ end def self.match_index 2 end def self.replace "#{trigger}{{ this }}" end def self.template '{{ this }}' end def self.strategy(hashtag_classes) super.tap { |obj| obj[:values] = compound_values(hashtag_classes) } end def self.compound_values(hashtag_classes) cls = Builder.new.filter_classes(variable_classes & hashtag_classes) cls.map { |i| i.values(hashtag_classes) }.flatten.compact end private # ============================================================= def hashtag(match) return unless name(match) [self.class.trigger, name(match)].join end def name(match) return unless self.class.values.include?(match[1]) match[1] end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
hashtags-0.1.2 | lib/hashtags/variable.rb |
hashtags-0.1.1 | lib/hashtags/variable.rb |
hashtags-0.1.0 | lib/hashtags/variable.rb |