Class: Ambition::Processors::Sort
- Inherits:
-
Base
show all
- Defined in:
- lib/ambition/processors/sort.rb
Instance Method Summary
collapse
Methods inherited from Base
#key, #process, #process_array, #process_dasgn_curr, #process_dvar, #process_false, #process_gvar, #process_ivar, #process_lit, #process_lvar, #process_nil, #process_proc, #process_str, #process_true, #rubify, #to_s, #translator, translator, #value
Constructor Details
#initialize(context, block) ⇒ Sort
Returns a new instance of Sort.
4
5
6
7
|
# File 'lib/ambition/processors/sort.rb', line 4
def initialize(context, block)
@context = context
@block = block
end
|
Instance Method Details
#process_call(args) ⇒ Object
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
|
# File 'lib/ambition/processors/sort.rb', line 9
def process_call(args)
if args.first.last == @receiver
translator.sort_by(*args[1..-1])
elsif args[0][1][-1] == @receiver && args.last == :-@
translator.reverse_sort_by(*args.first[2..-1])
elsif args[1] == :__send__
translator.to_proc(value('to_s'))
elsif args[0][1][-1] == @receiver
first = args.first.last
last = args.last
translator.chained_sort_by(first, last)
elsif args[0][1][1][-1] == @receiver && args.last == :-@
first = args.first[1].last
last = args.first.last
translator.chained_reverse_sort_by(first, last)
else
raise args.inspect
end
end
|
#process_masgn(exp) ⇒ Object
46
47
48
|
# File 'lib/ambition/processors/sort.rb', line 46
def process_masgn(exp)
''
end
|
#process_vcall(args) ⇒ Object
42
43
44
|
# File 'lib/ambition/processors/sort.rb', line 42
def process_vcall(args)
translator.send(args.shift, *args)
end
|