Module: KissShot::ObjC::Klass
Instance Method Summary collapse
-
#objc_class(name) ⇒ Object
Append @class forward declaration.
-
#objc_implementation(name) ⇒ Object
Append @implementation.
-
#objc_interface(name, superklass = "NSObject", protocols = nil) ⇒ Object
Append @interface.
-
#objc_interface_bracket ⇒ Object
interface raw bracket for instance variable.
-
#objc_interface_variable(name, type = 'NSInteger') ⇒ Object
Interface instance variable.
-
#objc_method(*args) ⇒ Object
Append method.
-
#objc_property(name, type, options = ['nonatomic', 'strong']) ⇒ Object
Append @property.
Methods included from Base
#_objc_bracket_array, #_objc_diamond_array
Instance Method Details
#objc_class(name) ⇒ Object
Append @class forward declaration
9 10 11 12 |
# File 'lib/kiss_shot/objc/klass.rb', line 9 def objc_class(name) line "@class #{name};" self end |
#objc_implementation(name) ⇒ Object
Append @implementation
31 32 33 34 35 |
# File 'lib/kiss_shot/objc/klass.rb', line 31 def objc_implementation(name) line "@implementation #{name}" yield if block_given? line "@end" end |
#objc_interface(name, superklass = "NSObject", protocols = nil) ⇒ Object
Append @interface
20 21 22 23 24 25 |
# File 'lib/kiss_shot/objc/klass.rb', line 20 def objc_interface(name, superklass = "NSObject", protocols = nil) line "@interface #{name} : #{superklass}#{_objc_diamond_array(Array.wrap(protocols))}" yield if block_given? line "@end" self end |
#objc_interface_bracket ⇒ Object
interface raw bracket for instance variable
39 40 41 42 43 44 45 46 |
# File 'lib/kiss_shot/objc/klass.rb', line 39 def objc_interface_bracket line "{" indent_up yield if block_given? indent_down line "}" self end |
#objc_interface_variable(name, type = 'NSInteger') ⇒ Object
Interface instance variable
52 53 54 |
# File 'lib/kiss_shot/objc/klass.rb', line 52 def objc_interface_variable(name, type = 'NSInteger') line "#{Array.wrap(type).join(" ")} #{name};" end |
#objc_method(*args) ⇒ Object
Append method
72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 |
# File 'lib/kiss_shot/objc/klass.rb', line 72 def objc_method(*args) sign = args.shift ? "+" : "-" type = args.shift raw "#{sign} (#{Array.wrap(type).join(" ")})", true if args.count == 1 raw " " raw "#{args.shift}" else raise "Bad args for #objc_method" unless args.count % 3 == 0 args.each_slice(3) do |slice| raw " " raw slice[0] raw ":" raw "(#{Array.wrap(slice[1]).join(" ")})" raw slice[2] end end if block_given? raw " {\n" indent_up yield indent_down line "}" else raw ";\n" end self end |
#objc_property(name, type, options = ['nonatomic', 'strong']) ⇒ Object
Append @property
62 63 64 65 |
# File 'lib/kiss_shot/objc/klass.rb', line 62 def objc_property(name, type, = ['nonatomic', 'strong']) line "@property #{_objc_bracket_array(Array.wrap(options))} #{Array.wrap(type).join(" ")} #{name};" self end |