Module: Ripper::RubyBuilder::Call

Included in:
Ripper::RubyBuilder
Defined in:
lib/ripper/ruby_builder/events/call.rb

Instance Method Summary collapse

Instance Method Details

#on_alias(*args) ⇒ Object



52
53
54
55
56
# File 'lib/ripper/ruby_builder/events/call.rb', line 52

def on_alias(*args)
  args.map! { |arg| arg.try(:to_identifier) || arg }
  identifier = pop_identifier(:@alias)
  Ruby::Alias.new(identifier, args)
end

#on_BEGIN(statements) ⇒ Object



108
109
110
111
112
113
# File 'lib/ripper/ruby_builder/events/call.rb', line 108

def on_BEGIN(statements)
  statements.ldelim = pop_token(:@lbrace)
  statements.rdelim = pop_token(:@rbrace)
  identifier = pop_identifier(:@BEGIN)
  Ruby::Call.new(nil, nil, identifier, nil, statements)
end

#on_break(args) ⇒ Object



85
86
87
88
# File 'lib/ripper/ruby_builder/events/call.rb', line 85

def on_break(args)
  identifier = pop_identifier(:@break)
  Ruby::Call.new(nil, nil, identifier, args)
end

#on_call(target, separator, identifier) ⇒ Object



15
16
17
18
19
20
# File 'lib/ripper/ruby_builder/events/call.rb', line 15

def on_call(target, separator, identifier)
  # happens for identifiers that are also keywords, e.g. :if
  identifier = pop_identifier(identifier.type) if identifier.try(:known?)
  separator = pop_token(:@period, :"@::", :left => target, :right => identifier)
  Ruby::Call.new(target, separator, identifier)
end

#on_command(identifier, args) ⇒ Object



4
5
6
# File 'lib/ripper/ruby_builder/events/call.rb', line 4

def on_command(identifier, args)
  Ruby::Call.new(nil, nil, identifier, args)
end

#on_command_call(target, separator, identifier, args) ⇒ Object



8
9
10
11
12
13
# File 'lib/ripper/ruby_builder/events/call.rb', line 8

def on_command_call(target, separator, identifier, args)
  # happens for identifiers that are operators, e.g. a.<<(foo)
  identifier = pop_identifier(identifier.type) if identifier.try(:known?)
  separator = pop_token(:@period, :"@::")
  Ruby::Call.new(target, separator, identifier, args)
end

#on_defined(ref) ⇒ Object



100
101
102
103
104
105
106
# File 'lib/ripper/ruby_builder/events/call.rb', line 100

def on_defined(ref)
  identifer = pop_identifier(:@defined, :pass => true)
  ldelim = pop_token(:@lparen, :left => identifer)
  rdelim = pop_token(:@rparen) if ldelim
  args = Ruby::ArgsList.new(ref, ldelim, rdelim)
  Ruby::Call.new(nil, nil, identifer, args)
end

#on_END(statements) ⇒ Object



115
116
117
118
119
120
# File 'lib/ripper/ruby_builder/events/call.rb', line 115

def on_END(statements)
  statements.ldelim = pop_token(:@lbrace)
  statements.rdelim = pop_token(:@rbrace)
  identifier = pop_identifier(:@END)
  Ruby::Call.new(nil, nil, identifier, nil, statements)
end

#on_fcall(identifier) ⇒ Object



22
23
24
# File 'lib/ripper/ruby_builder/events/call.rb', line 22

def on_fcall(identifier)
  Ruby::Call.new(nil, nil, identifier)
end

#on_field(target, separator, identifier) ⇒ Object

assignment methods, e.g. a.b = :c



27
28
29
30
# File 'lib/ripper/ruby_builder/events/call.rb', line 27

def on_field(target, separator, identifier)
  separator = pop_token(:@period, :"@::")
  Ruby::Call.new(target, separator, identifier)
end

#on_next(args) ⇒ Object



80
81
82
83
# File 'lib/ripper/ruby_builder/events/call.rb', line 80

def on_next(args)
  identifier = pop_identifier(:@next)
  Ruby::Call.new(nil, nil, identifier, args)
end

#on_redoObject



90
91
92
93
# File 'lib/ripper/ruby_builder/events/call.rb', line 90

def on_redo
  identifier = pop_identifier(:@redo)
  Ruby::Call.new(nil, nil, identifier)
end

#on_retryObject



95
96
97
98
# File 'lib/ripper/ruby_builder/events/call.rb', line 95

def on_retry
  identifier = pop_identifier(:@retry)
  Ruby::Call.new(nil, nil, identifier)
end

#on_return(args) ⇒ Object



75
76
77
78
# File 'lib/ripper/ruby_builder/events/call.rb', line 75

def on_return(args)
  identifier = pop_identifier(:@return)
  Ruby::Call.new(nil, nil, identifier, args)
end

#on_return0Object



70
71
72
73
# File 'lib/ripper/ruby_builder/events/call.rb', line 70

def on_return0
  identifier = pop_identifier(:@return)
  Ruby::Call.new(nil, nil, identifier, nil)
end

#on_super(args) ⇒ Object



37
38
39
40
# File 'lib/ripper/ruby_builder/events/call.rb', line 37

def on_super(args)
  identifier = pop_identifier(:@super)
  Ruby::Call.new(nil, nil, identifier, args)
end

#on_undef(args) ⇒ Object



64
65
66
67
68
# File 'lib/ripper/ruby_builder/events/call.rb', line 64

def on_undef(args)
  args = Ruby::ArgsList.new(args, pop_tokens(:@comma))
  identifier = pop_identifier(:@undef)
  Ruby::Call.new(nil, nil, identifier, args)
end

#on_var_alias(*args) ⇒ Object



58
59
60
61
62
# File 'lib/ripper/ruby_builder/events/call.rb', line 58

def on_var_alias(*args)
  args.map! { |arg| arg.try(:to_identifier) || arg }
  identifier = pop_identifier(:@alias)
  Ruby::Alias.new(identifier, args)
end

#on_yield(args) ⇒ Object



42
43
44
45
# File 'lib/ripper/ruby_builder/events/call.rb', line 42

def on_yield(args)
  identifier = pop_identifier(:@yield)
  Ruby::Call.new(nil, nil, identifier, args)
end

#on_yield0Object



47
48
49
50
# File 'lib/ripper/ruby_builder/events/call.rb', line 47

def on_yield0
  identifier = pop_identifier(:@yield)
  Ruby::Call.new(nil, nil, identifier)
end

#on_zsuper(*args) ⇒ Object



32
33
34
35
# File 'lib/ripper/ruby_builder/events/call.rb', line 32

def on_zsuper(*args)
  identifier = pop_identifier(:@super)
  Ruby::Call.new(nil, nil, identifier)
end