Class: Converter
- Inherits:
-
Object
- Object
- Converter
- Defined in:
- lib/converter.rb
Instance Attribute Summary collapse
-
#properties ⇒ Object
Returns the value of attribute properties.
-
#release ⇒ Object
Returns the value of attribute release.
-
#synthesize ⇒ Object
Returns the value of attribute synthesize.
-
#unload ⇒ Object
Returns the value of attribute unload.
Instance Method Summary collapse
- #convert ⇒ Object
-
#initialize(selection) ⇒ Converter
constructor
A new instance of Converter.
Constructor Details
#initialize(selection) ⇒ Converter
Returns a new instance of Converter.
6 7 8 9 10 11 12 13 14 15 16 17 |
# File 'lib/converter.rb', line 6 def initialize(selection) @properties = '' @synthesize = '' @release = '' @unload = '' @selection = selection @copy = Configuration.types['copy'] @assign = Configuration.types['assign'] @use_nonatomic = Configuration.settings['use_nonatomic'] @outlet = Configuration.settings['outlet'] end |
Instance Attribute Details
#properties ⇒ Object
Returns the value of attribute properties.
4 5 6 |
# File 'lib/converter.rb', line 4 def properties @properties end |
#release ⇒ Object
Returns the value of attribute release.
4 5 6 |
# File 'lib/converter.rb', line 4 def release @release end |
#synthesize ⇒ Object
Returns the value of attribute synthesize.
4 5 6 |
# File 'lib/converter.rb', line 4 def synthesize @synthesize end |
#unload ⇒ Object
Returns the value of attribute unload.
4 5 6 |
# File 'lib/converter.rb', line 4 def unload @unload end |
Instance Method Details
#convert ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/converter.rb', line 19 def convert @selection.split("\n").each do |line| line = line.scan("*") == [] ? line.strip : line.gsub!(/\*/, '').strip words = line.split(/\s+/) label = words.size > 2 ? words[1] : words[0] variable = words[-1] mem_label = memory_management(label) star = mem_label == 'assign' ? '' : '*' @properties << "@property (#{use_nonatomic(mem_label)}) #{("IBOutlet " if @outlet)}#{label} #{star}#{variable}\n" @synthesize << "@synthesize #{variable}\n" @release << "\tself.#{clean_var(variable)} = nil;\n" unless mem_label == 'assign' @unload << "\tself.#{clean_var(variable)} = nil;\n" end end |