Class: Fus::SwiftClass
- Inherits:
-
Object
- Object
- Fus::SwiftClass
- Defined in:
- lib/fus/swift_class.rb
Overview
A thin wrapper around the name of a Swift class
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Instance Method Summary collapse
-
#initialize(name) ⇒ SwiftClass
constructor
A new instance of SwiftClass.
-
#matches_classname?(path) ⇒ Boolean
Does this class name match this path.
-
#spec? ⇒ Boolean
Is this class a test class.
-
#used_in_obj_c?(text) ⇒ Boolean
Is this class used in this Obj-C text.
-
#used_in_swift?(text) ⇒ Boolean
Is this class used in this Swift text.
-
#used_in_xml?(xml) ⇒ Boolean
Is this class used in this XML.
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
#name ⇒ Object (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
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
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
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
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
20 21 22 |
# File 'lib/fus/swift_class.rb', line 20 def used_in_xml?(xml) xml.include?("customClass=\"#{name}\"") end |