Class: Fus::SwiftClass

Inherits:
Object
  • Object
show all
Defined in:
lib/fus/swift_class.rb

Overview

A thin wrapper around the name of a Swift class

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name) ⇒ SwiftClass

Returns a new instance of SwiftClass.



5
6
7
# File 'lib/fus/swift_class.rb', line 5

def initialize(name)
  @name = name.sub(/<.+>/, "")
end

Instance Attribute Details

#nameObject (readonly)

Returns the value of attribute name.



4
5
6
# File 'lib/fus/swift_class.rb', line 4

def name
  @name
end

Instance Method Details

#matches_classname?(path) ⇒ Boolean

Does this class name match this path

Returns:

  • (Boolean)


15
16
17
# File 'lib/fus/swift_class.rb', line 15

def matches_classname?(path)
  path.match(/#{name}\b/)
end

#spec?Boolean

Is this class a test class

Returns:

  • (Boolean)


10
11
12
# File 'lib/fus/swift_class.rb', line 10

def spec?
  name.match(/Spec|Tests|Test/)
end

#used_in_obj_c?(text) ⇒ Boolean

Is this class used in this Obj-C text

Returns:

  • (Boolean)


25
26
27
# File 'lib/fus/swift_class.rb', line 25

def used_in_obj_c?(text)
  text.match(/(^|[^@])#{name}/)
end

#used_in_swift?(text) ⇒ Boolean

Is this class used in this Swift text

Returns:

  • (Boolean)


30
31
32
# File 'lib/fus/swift_class.rb', line 30

def used_in_swift?(text)
  text.match(/(\b#{name}(<.+>)?.?[.(])|([:].?#{name})|((typealias|associatedType)\s+.*=.+#{name})/)
end

#used_in_xml?(xml) ⇒ Boolean

Is this class used in this XML

Returns:

  • (Boolean)


20
21
22
# File 'lib/fus/swift_class.rb', line 20

def used_in_xml?(xml)
  xml.include?("customClass=\"#{name}\"")
end