Class: KZ::KZSwiftEnum
- Inherits:
-
KZSwiftContext
- Object
- KZSwiftContext
- KZ::KZSwiftEnum
- Defined in:
- lib/cocoapods-kz/helpers/repair_dynamic_swift.rb
Class Method Summary collapse
Instance Method Summary collapse
- #get_oc_feature_contexts ⇒ Object
-
#initialize(type_contexts) ⇒ KZSwiftEnum
constructor
A new instance of KZSwiftEnum.
Constructor Details
#initialize(type_contexts) ⇒ KZSwiftEnum
Returns a new instance of KZSwiftEnum.
179 180 181 182 183 |
# File 'lib/cocoapods-kz/helpers/repair_dynamic_swift.rb', line 179 def initialize(type_contexts) super(type_contexts) do |line| return KZSwiftEnum.check_line_have_enum_tag(line) end end |
Class Method Details
.check_line_have_enum_tag(line) ⇒ Object
185 186 187 188 189 190 191 |
# File 'lib/cocoapods-kz/helpers/repair_dynamic_swift.rb', line 185 def self.check_line_have_enum_tag(line) if line =~ /^(?:.*\s)?enum\s/ return true else return false end end |
Instance Method Details
#get_oc_feature_contexts ⇒ Object
193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 |
# File 'lib/cocoapods-kz/helpers/repair_dynamic_swift.rb', line 193 def get_oc_feature_contexts new_enum_context = [] have_objc_tag = false for ornament in @type_ornament if ornament.start_with?("@objc ") || ornament.start_with?("@objc(") || ornament == "@objc" have_objc_tag = true end end return @type_contexts if have_objc_tag for enum_line in @type_contexts if KZSwiftEnum.check_line_have_enum_tag(enum_line) raw_value_type = "" raw_value_type = $1 if enum_line =~ /^.*:\s*(\w+)\s*{/ if raw_value_type == "Int" new_enum_context.insert(0, "@objc\n") else return @type_contexts end end new_enum_context << enum_line end new_enum_context end |