Class: Spider::QueryFuncs::Expression
- Inherits:
-
Object
- Object
- Spider::QueryFuncs::Expression
- Defined in:
- lib/spiderfw/model/query_funcs.rb
Instance Method Summary (collapse)
- - (Object) []=(el, replacement)
- - (Object) each_element
-
- (Expression) initialize(string)
constructor
A new instance of Expression.
- - (Object) to_s
Constructor Details
- (Expression) initialize(string)
A new instance of Expression
25 26 27 28 |
# File 'lib/spiderfw/model/query_funcs.rb', line 25 def initialize(string) @string = string @replacements = {} end |
Instance Method Details
- (Object) []=(el, replacement)
34 35 36 |
# File 'lib/spiderfw/model/query_funcs.rb', line 34 def []=(el, replacement) @replacements[el] = replacement end |
- (Object) each_element
30 31 32 |
# File 'lib/spiderfw/model/query_funcs.rb', line 30 def each_element @string.scan(/:\w[\w\d\.]+/).each{ |el| yield el[1..-1].to_sym } end |
- (Object) to_s
38 39 40 41 42 43 44 |
# File 'lib/spiderfw/model/query_funcs.rb', line 38 def to_s str = @string @replacements.each do |el, rep| str = str.gsub(":#{el}", rep) end return str end |