Class: Referee::ViewController
- Inherits:
-
Renderable
- Object
- Renderable
- Referee::ViewController
- Defined in:
- lib/referee/renderables/viewcontroller.rb
Overview
Renderable implementation for UIViewControllers embedded in storyboards.
Instance Attribute Summary collapse
-
#config ⇒ Object
Returns the value of attribute config.
-
#name ⇒ Object
Returns the value of attribute name.
-
#storyboard ⇒ Object
Returns the value of attribute storyboard.
Attributes inherited from Renderable
Instance Method Summary collapse
- #declaration ⇒ Object
- #implementation ⇒ Object
-
#initialize(name, klass, storyboard, config) ⇒ ViewController
constructor
A new instance of ViewController.
- #method_name ⇒ Object
- #swift_implementation ⇒ Object
Methods inherited from Renderable
#bundle_accessor, #methodize_name, #simple_method_declaration, #simple_method_implementation, #simple_swift_method, #simple_swift_string_case, #swift_bundle_accessor
Constructor Details
#initialize(name, klass, storyboard, config) ⇒ ViewController
6 7 8 9 10 11 12 13 |
# File 'lib/referee/renderables/viewcontroller.rb', line 6 def initialize(name, klass, storyboard, config) @name = name @class = klass @storyboard = storyboard @type = "#{@class} *" @swift_type = @class @config = config end |
Instance Attribute Details
#config ⇒ Object
Returns the value of attribute config.
4 5 6 |
# File 'lib/referee/renderables/viewcontroller.rb', line 4 def config @config end |
#name ⇒ Object
Returns the value of attribute name.
4 5 6 |
# File 'lib/referee/renderables/viewcontroller.rb', line 4 def name @name end |
#storyboard ⇒ Object
Returns the value of attribute storyboard.
4 5 6 |
# File 'lib/referee/renderables/viewcontroller.rb', line 4 def storyboard @storyboard end |
Instance Method Details
#declaration ⇒ Object
19 20 21 |
# File 'lib/referee/renderables/viewcontroller.rb', line 19 def declaration simple_method_declaration method_name end |
#implementation ⇒ Object
23 24 25 26 27 28 |
# File 'lib/referee/renderables/viewcontroller.rb', line 23 def implementation bundle = bundle_accessor(@config.bundle_id) body = "(#{@type})[[UIStoryboard storyboardWithName:@\"#{@storyboard}\" bundle:#{bundle}] " \ "instantiateViewControllerWithIdentifier:@\"#{@name}\"]" simple_method_implementation method_name, body end |
#method_name ⇒ Object
15 16 17 |
# File 'lib/referee/renderables/viewcontroller.rb', line 15 def method_name "new#{@name}" end |
#swift_implementation ⇒ Object
30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/referee/renderables/viewcontroller.rb', line 30 def swift_implementation bundle = swift_bundle_accessor(@config.bundle_id) if @swift_type == 'UIViewController' cast = '' else cast = " as! #{@swift_type}" end body = "UIStoryboard(name: \"#{@storyboard}\", bundle: #{bundle})." \ "instantiateViewControllerWithIdentifier(\"#{@name}\")#{cast}" simple_swift_method method_name, body end |