Class: Udgenerator::Objective
- Inherits:
-
Object
- Object
- Udgenerator::Objective
- Defined in:
- lib/udgenerator/objective.rb
Instance Method Summary collapse
Instance Method Details
#object(type) ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/udgenerator/objective.rb', line 19 def object(type) if "NSString" == type NSString.new() elsif "NSNumber" == type NSNumber.new() elsif "NSArray" == type NSArray.new() elsif "NSDictionary" == type NSDictionary.new() elsif "NSData" == type NSData.new() elsif "NSDate" == type NSDate.new() else AnyObject.new("#{type}") end end |
#parse(arrStr) ⇒ Object
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
# File 'lib/udgenerator/objective.rb', line 4 def parse(arrStr) result = {} arrStr.each{|s| if /\s*(\w+) *\* *(\w+)\s*;\s*/ =~ s then result[$2] = object($1) elsif /- \((\w+) *\* *\)(\w+);/ =~ s then result[$2] = object($1) elsif /\s*(\w+)\s+(\w+)\s*;\s*/ =~ s then result[$2] = value($1) elsif /- \((\w+)\)(\w+);/ =~ s then result[$2] = value($1) end } result end |
#value(type) ⇒ Object
36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/udgenerator/objective.rb', line 36 def value(type) if "NSInteger" == type then NSInteger.new() elsif "BOOL" == type then NSBOOL.new() elsif "float" == type then NSFloat.new() elsif "double" == type then NSDouble.new() else AnyObject.new("#{type}") end end |