Class: Eco::Language::MatchModifier
Constant Summary
collapse
- VALUE_MODE =
[ :value, :is, ]
- PATTERN_MODE =
[ :pattern, :contains, :regexp ]
- REVERSE_MODE =
[ :reverse, :at_to_value, :<< ]
- NON_REVERSE_MODE =
[ :normal, :value_to_at, :non_reverse, :>> ]
- ALL_MODE =
[ :all, :every ]
- ANY_MODE =
[ :any, :some ]
- AND_MODE =
[ :AND, :and, :&, :intersection, :intersect ]
- OR_MODE =
[ :OR, :or, :|, :union ]
- CASE_MODE =
[ :c, :case_sensitive, :case, :sensitive ]
- INCASE_MODE =
[ :i, :case_insensitive, :insensitive ]
- YES_MODE =
[ :==, :YES, :yes, :true, :include, :eq ]
- NOT_MODE =
[ :!, :NOT, :not, :false, :exclude, :diff ]
Eco::Language::Models::Modifier::DEFAULT_MODE
Instance Method Summary
collapse
#<, #<<, #default, #default?, #flush_mode, #initialize, #mode, #new, #reset
Instance Method Details
87
88
89
|
# File 'lib/eco/language/match_modifier.rb', line 87
def all
every
end
|
#all? ⇒ Boolean
151
152
153
|
# File 'lib/eco/language/match_modifier.rb', line 151
def all?
mode.any? { |m| ALL_MODE.include?(m) }
end
|
99
100
101
|
# File 'lib/eco/language/match_modifier.rb', line 99
def and
self.push(:and)
end
|
#and? ⇒ Boolean
159
160
161
|
# File 'lib/eco/language/match_modifier.rb', line 159
def and?
mode.any? { |m| AND_MODE.include?(m) }
end
|
95
96
97
|
# File 'lib/eco/language/match_modifier.rb', line 95
def any
some
end
|
#any? ⇒ Boolean
143
144
145
|
# File 'lib/eco/language/match_modifier.rb', line 143
def any?
mode.any? {|m| ANY_MODE.include?(m)}
end
|
107
108
109
|
# File 'lib/eco/language/match_modifier.rb', line 107
def case
self.push(:sensitive)
end
|
#case_sensitive? ⇒ Boolean
171
172
173
|
# File 'lib/eco/language/match_modifier.rb', line 171
def case_sensitive?
mode.any? { |m| CASE_MODE.include?(m) }
end
|
63
64
65
|
# File 'lib/eco/language/match_modifier.rb', line 63
def debug
self.push(:debug)
end
|
#debug? ⇒ Boolean
123
124
125
|
# File 'lib/eco/language/match_modifier.rb', line 123
def debug?
mode.any? {|m| m == :debug}
end
|
115
116
117
|
# File 'lib/eco/language/match_modifier.rb', line 115
def eq
self.push(:eq)
end
|
83
84
85
|
# File 'lib/eco/language/match_modifier.rb', line 83
def every
self.push(:every)
end
|
#every? ⇒ Boolean
155
156
157
|
# File 'lib/eco/language/match_modifier.rb', line 155
def every?
self.all?
end
|
#insensitive ⇒ Object
111
112
113
|
# File 'lib/eco/language/match_modifier.rb', line 111
def insensitive
self.push(:insensitive)
end
|
#insensitive? ⇒ Boolean
167
168
169
|
# File 'lib/eco/language/match_modifier.rb', line 167
def insensitive?
mode.any? { |m| INCASE_MODE.include?(m) }
end
|
#non_reverse? ⇒ Boolean
139
140
141
|
# File 'lib/eco/language/match_modifier.rb', line 139
def non_reverse?
mode.any? {|m| NON_REVERSE_MODE.include?(m)}
end
|
79
80
81
|
# File 'lib/eco/language/match_modifier.rb', line 79
def normal
self.push(:normal)
end
|
119
120
121
|
# File 'lib/eco/language/match_modifier.rb', line 119
def not
self.push(:not)
end
|
#not? ⇒ Boolean
175
176
177
|
# File 'lib/eco/language/match_modifier.rb', line 175
def not?
mode.any? { |m| NOT_MODE.include?(m) }
end
|
103
104
105
|
# File 'lib/eco/language/match_modifier.rb', line 103
def or
self.push(:or)
end
|
#or? ⇒ Boolean
163
164
165
|
# File 'lib/eco/language/match_modifier.rb', line 163
def or?
mode.any? { |m| OR_MODE.include?(m) }
end
|
67
68
69
|
# File 'lib/eco/language/match_modifier.rb', line 67
def pattern
self.push(:pattern)
end
|
#pattern? ⇒ Boolean
127
128
129
|
# File 'lib/eco/language/match_modifier.rb', line 127
def pattern?
mode.any? {|m| PATTERN_MODE.include?(m)}
end
|
#reset_and ⇒ Object
51
52
53
|
# File 'lib/eco/language/match_modifier.rb', line 51
def reset_and
self < self.mode - (AND_MODE | OR_MODE)
end
|
#reset_case ⇒ Object
55
56
57
|
# File 'lib/eco/language/match_modifier.rb', line 55
def reset_case
self < self.mode - (INCASE_MODE | CASE_MODE)
end
|
#reset_every ⇒ Object
47
48
49
|
# File 'lib/eco/language/match_modifier.rb', line 47
def reset_every
self < self.mode - (ALL_MODE | ANY_MODE)
end
|
#reset_not ⇒ Object
59
60
61
|
# File 'lib/eco/language/match_modifier.rb', line 59
def reset_not
self < self.mode - (NOT_MODE | YES_MODE)
end
|
#reset_pattern ⇒ Object
39
40
41
|
# File 'lib/eco/language/match_modifier.rb', line 39
def reset_pattern
self < self.mode - (PATTERN_MODE | VALUE_MODE)
end
|
75
76
77
|
# File 'lib/eco/language/match_modifier.rb', line 75
def reverse
self.push(:reverse)
end
|
#reverse? ⇒ Boolean
135
136
137
|
# File 'lib/eco/language/match_modifier.rb', line 135
def reverse?
mode.any? {|m| REVERSE_MODE.include?(m)}
end
|
91
92
93
|
# File 'lib/eco/language/match_modifier.rb', line 91
def some
self.push(:some)
end
|
#some? ⇒ Boolean
147
148
149
|
# File 'lib/eco/language/match_modifier.rb', line 147
def some?
self.any?
end
|
#to_regex(value) ⇒ Object
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
|
# File 'lib/eco/language/match_modifier.rb', line 23
def to_regex(value)
case
when value.is_a?(Array)
return value.map { |v| self.to_regex(v) }
when value.is_a?(Regexp)
return value
when value.is_a?(String)
esub = Regexp.escape(value)
if self.insensitive?
return /#{esub}/i
else
return /#{esub}/
end
end
end
|
71
72
73
|
# File 'lib/eco/language/match_modifier.rb', line 71
def value
self.push(:value)
end
|
#value? ⇒ Boolean
131
132
133
|
# File 'lib/eco/language/match_modifier.rb', line 131
def value?
mode.any? {|m| VALUE_MODE.include?(m)}
end
|
#yes? ⇒ Boolean
179
180
181
|
# File 'lib/eco/language/match_modifier.rb', line 179
def yes?
mode.any? { |m| YES_MODE.include?(m) }
end
|