Class: ObjcStep

Inherits:
Step
  • Object
show all
Defined in:
lib/ObjC/objc_step.rb

Instance Attribute Summary

Attributes inherited from Step

#body, #message, #parent

Instance Method Summary collapse

Methods inherited from Step

#aggregate!, #args, #has_args?, #initialize, #to_html

Constructor Details

This class inherits a constructor from Step

Instance Method Details

#args_stringObject



6
7
8
9
10
11
12
13
# File 'lib/ObjC/objc_step.rb', line 6

def args_string
  if has_args?
    ([":@\"#{args[0]}\""] + 
    (args[1..args.length] || []).map { |a| "arg:@\"#{a}\"" }).join(" ")
  else
    ""
  end
end

#first_partObject



2
3
4
# File 'lib/ObjC/objc_step.rb', line 2

def first_part
  body.gsub(/\s+/,"_").gsub(/'[^']*'/, "__").remove_invalid_chars
end

#parameter_stringObject



19
20
21
22
23
24
25
26
27
28
29
# File 'lib/ObjC/objc_step.rb', line 19

def parameter_string
  if has_args?
    s = ":(NSString *)arg "
    (args[1..args.length] || []).each_with_index do |a, i|
      s << "arg:(NSString *)arg#{i+2} "
    end
    s
  else
    ""
  end
end

#to_ocmethodObject



31
32
33
34
35
36
37
38
# File 'lib/ObjC/objc_step.rb', line 31

def to_ocmethod
  <<-END
-(void) #{first_part + parameter_string}
{

}
  END
end

#to_sObject



15
16
17
# File 'lib/ObjC/objc_step.rb', line 15

def to_s
  "[self #{message}];"
end