Class: Spider::QueryFuncs::Function

Inherits:
Object
  • Object
show all
Defined in:
lib/spiderfw/model/query_funcs.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#mapper_fieldsObject

Returns the value of attribute mapper_fields



49
50
51
# File 'lib/spiderfw/model/query_funcs.rb', line 49

def mapper_fields
  @mapper_fields
end

Class Method Details

.func_nameObject



56
57
58
59
# File 'lib/spiderfw/model/query_funcs.rb', line 56

def self.func_name
    self.name =~ /::([^:]+)$/
    return Inflector.underscore($1).to_sym
end

.inherited(subclass) ⇒ Object



51
52
53
54
# File 'lib/spiderfw/model/query_funcs.rb', line 51

def self.inherited(subclass)
    cl_name = subclass.name.split('::')[-1].to_sym
    Spider::QueryFuncs.add_query_func(cl_name, subclass)
end

Instance Method Details

#aggregate?Boolean



81
82
83
# File 'lib/spiderfw/model/query_funcs.rb', line 81

def aggregate?
    false
end

#elementsObject



65
66
67
# File 'lib/spiderfw/model/query_funcs.rb', line 65

def elements
    []
end

#func_nameObject



61
62
63
# File 'lib/spiderfw/model/query_funcs.rb', line 61

def func_name
    self.class.func_name
end

#has_aggregates?Boolean



85
86
87
88
89
90
91
# File 'lib/spiderfw/model/query_funcs.rb', line 85

def has_aggregates?
    return true if aggregate?
    elements.each do |el|
        return true if el.is_a?(Function) && el.has_aggregates?
    end
    return false
end

#inner_elementsObject



69
70
71
72
73
74
75
76
77
78
79
# File 'lib/spiderfw/model/query_funcs.rb', line 69

def inner_elements
    els = []
    elements.each do |el|
        if (el.is_a?(Function))
            els += el.inner_elements
        else
            els << [el, self]
        end
    end
    return els
end

#inspectObject



93
94
95
# File 'lib/spiderfw/model/query_funcs.rb', line 93

def inspect
    "#{self.func_name.to_s.upcase}(#{elements.map{ |el| el.inspect }.join(', ')})"
end