Class: Card::Content::Chunk::QueryReference
- Inherits:
-
Reference
show all
- Defined in:
- mod/content/lib/card/content/chunk/query_reference.rb
Constant Summary
collapse
- QUERY_KEYWORDS =
::Set.new(
(
Query::MODIFIERS.keys +
Query::OPERATORS.keys +
Query.attributes.keys +
Query::CONJUNCTIONS.keys +
%w[desc asc count]
).map(&:to_s)
)
Instance Attribute Summary
Attributes inherited from Reference
#name, #referee_name
Attributes inherited from Abstract
#text
Class Method Summary
collapse
Instance Method Summary
collapse
Methods inherited from Reference
#referee_card, #referee_raw_name
Methods inherited from Abstract
#as_json, #burn_after_reading, #burn_read, #card, context_ok?, #format, full_re, #initialize, #result, #to_s
Class Method Details
.full_match(content, prefix) ⇒ Object
56
57
58
59
60
61
62
63
|
# File 'mod/content/lib/card/content/chunk/query_reference.rb', line 56
def full_match content, prefix
match, offset = super(content, prefix)
return if !match || keyword?(match[1])
[match, offset]
end
|
.keyword?(str) ⇒ Boolean
65
66
67
68
69
|
# File 'mod/content/lib/card/content/chunk/query_reference.rb', line 65
def keyword? str
return unless str
QUERY_KEYWORDS.include?(str.tr(" ", "_").downcase)
end
|
Instance Method Details
80
81
82
|
# File 'mod/content/lib/card/content/chunk/query_reference.rb', line 80
def inspect
"<##{self.class}:n[#{@name}] p[#{@process_chunk}] txt:#{@text}>"
end
|
#interpret(match, _content) ⇒ Object
72
73
74
|
# File 'mod/content/lib/card/content/chunk/query_reference.rb', line 72
def interpret match, _content
@name = match[1]
end
|
#process_chunk ⇒ Object
76
77
78
|
# File 'mod/content/lib/card/content/chunk/query_reference.rb', line 76
def process_chunk
@process_chunk ||= @text
end
|
#reference_code ⇒ Object
89
90
91
|
# File 'mod/content/lib/card/content/chunk/query_reference.rb', line 89
def reference_code
"Q" end
|
#swap_name(old_name, new_name) ⇒ Object
84
85
86
87
|
# File 'mod/content/lib/card/content/chunk/query_reference.rb', line 84
def swap_name old_name, new_name
replace_name_reference old_name, new_name
@text = "\"#{@name}\""
end
|