Class: Hashtags::Variable

Inherits:
Base
  • Object
show all
Defined in:
lib/hashtags/variable.rb

Instance Attribute Summary

Attributes inherited from Base

#str

Class Method Summary collapse

Methods inherited from Base

cache_key, descendants, json_for_query, json_regexp, #markup, match_template, path, resource_classes, to_hashtag, #to_hashtag, to_markup, #to_markup, user_classes, variable_classes

Class Method Details

.compound_values(hashtag_classes) ⇒ Object



42
43
44
45
# File 'lib/hashtags/variable.rb', line 42

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

.help_valuesObject



15
16
17
# File 'lib/hashtags/variable.rb', line 15

def self.help_values
  values
end

.match_indexObject



26
27
28
# File 'lib/hashtags/variable.rb', line 26

def self.match_index
  2
end

.match_regexpObject


JS



22
23
24
# File 'lib/hashtags/variable.rb', line 22

def self.match_regexp
  /(#{Regexp.escape(trigger)})(\w{1,})\z/
end

.regexpObject



7
8
9
# File 'lib/hashtags/variable.rb', line 7

def self.regexp
  /#{Regexp.escape(trigger)}(.+?)\b/i
end

.replaceObject



30
31
32
# File 'lib/hashtags/variable.rb', line 30

def self.replace
  "#{trigger}{{ this }}"
end

.strategy(hashtag_classes) ⇒ Object



38
39
40
# File 'lib/hashtags/variable.rb', line 38

def self.strategy(hashtag_classes)
  super.tap { |obj| obj[:values] = compound_values(hashtag_classes) }
end

.templateObject



34
35
36
# File 'lib/hashtags/variable.rb', line 34

def self.template
  '{{ this }}'
end

.triggerObject



3
4
5
# File 'lib/hashtags/variable.rb', line 3

def self.trigger
  '$'
end

.values(hashtag_classes = Variable.descendants) ⇒ Object

Raises:

  • (NotImplemented)


11
12
13
# File 'lib/hashtags/variable.rb', line 11

def self.values(hashtag_classes = Variable.descendants)
  raise NotImplemented
end