Class: KZ::KZSwiftContext
- Inherits:
-
Object
- Object
- KZ::KZSwiftContext
- Defined in:
- lib/cocoapods-kz/helpers/repair_dynamic_swift.rb
Direct Known Subclasses
Instance Method Summary collapse
- #get_oc_feature_contexts ⇒ Object
-
#initialize(type_contexts) ⇒ KZSwiftContext
constructor
A new instance of KZSwiftContext.
Constructor Details
#initialize(type_contexts) ⇒ KZSwiftContext
Returns a new instance of KZSwiftContext.
5 6 7 8 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 41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/cocoapods-kz/helpers/repair_dynamic_swift.rb', line 5 def initialize(type_contexts) @type_contexts = type_contexts @type_ornament = [] @type_header = [] @type_str = "" @type_body = [] if @type_contexts.length == 1 element = @type_contexts[0] puts @type_contexts @type_ornament = element.scan(/@\w+[()\w\n]*/) element_info = element.split("{") @type_str = element_info[0] + "{" @type_body << element_info[1].sub("}", "") else # 1 从未扫描到class 2 扫描到class 3 class扫描完毕 type_line_tag = 1 type_lines = [] for type_line in @type_contexts if type_line_tag == 1 ornaments = type_line.scan(/@\w+[()\w\n]*/) @type_ornament.concat(ornaments) if ornaments.length > 0 result = yield(type_line) if result type_line_tag = 2 else @type_header << type_line next end end if type_line_tag == 2 type_lines << type_line if type_line.include?("{") type_line_tag = 3 @type_str = type_lines.join("") end next end @type_body << type_line end last_element = @type_body[-1] @type_body.pop() @type_body << last_element.sub("}", "") end end |
Instance Method Details
#get_oc_feature_contexts ⇒ Object
55 56 57 |
# File 'lib/cocoapods-kz/helpers/repair_dynamic_swift.rb', line 55 def get_oc_feature_contexts @type_contexts end |