Class: Spider::QueryFuncs::Expression
- Defined in:
- lib/spiderfw/model/query_funcs.rb
Instance Method Summary collapse
- #[]=(el, replacement) ⇒ Object
- #each_element ⇒ Object
-
#initialize(string) ⇒ Expression
constructor
A new instance of Expression.
- #to_s ⇒ Object
Constructor Details
#initialize(string) ⇒ Expression
Returns 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
#[]=(el, replacement) ⇒ Object
34 35 36 |
# File 'lib/spiderfw/model/query_funcs.rb', line 34 def []=(el, replacement) @replacements[el] = replacement end |
#each_element ⇒ Object
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 |
#to_s ⇒ Object
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 |