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

- (Object) mapper_fields

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

+ (Object) func_name



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

+ (Object) inherited(subclass)



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

- (Boolean) aggregate?



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

def aggregate?
    false
end

- (Object) elements



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

def elements
    []
end

- (Object) func_name



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

def func_name
    self.class.func_name
end

- (Boolean) has_aggregates?



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

- (Object) inner_elements



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

- (Object) inspect



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