class Stronglyboards::Storyboard
Constants
- EXTENSION
Attributes
name[R]
view_controllers[R]
Public Class Methods
new(full_path)
click to toggle source
# File lib/stronglyboards/storyboard.rb, line 12 def initialize(full_path) @name = File.basename(full_path, EXTENSION) file = File.open(full_path) @xml = Nokogiri::XML(file) file.close @view_controllers = Array.new # Find the initial view controller initial_view_controller = find_initial_view_controller @view_controllers.push(initial_view_controller) if initial_view_controller # Find other view controllers @view_controllers += find_view_controllers_with_storyboard_identifiers end
Public Instance Methods
class_name(prefix = nil)
click to toggle source
# File lib/stronglyboards/storyboard.rb, line 54 def class_name(prefix = nil) prefix + @name + 'Storyboard' end
lowercase_name(prefix = nil)
click to toggle source
# File lib/stronglyboards/storyboard.rb, line 58 def lowercase_name(prefix = nil) lower = @name.dup lower[0] = lower[0].downcase if prefix == nil || prefix.length == 0 lower else prefix.downcase + '_' + lower end end
Private Instance Methods
find_initial_view_controller()
click to toggle source
Searches for the initial view controller
# File lib/stronglyboards/storyboard.rb, line 31 def find_initial_view_controller initial_vc_identifier = @xml.at_xpath('document').attr('initialViewController') view_controller_xml = object_with_identifier(initial_vc_identifier) if initial_vc_identifier if view_controller_xml ViewController.new(view_controller_xml, true) end end
find_view_controllers_with_storyboard_identifiers()
click to toggle source
Searches for view controllers
# File lib/stronglyboards/storyboard.rb, line 41 def find_view_controllers_with_storyboard_identifiers view_controllers = @xml.xpath('//scene/objects/*[@storyboardIdentifier]') view_controllers.collect { |xml| ViewController.new(xml) } if view_controllers end
object_with_identifier(identifier)
click to toggle source
——— Helpers ———
# File lib/stronglyboards/storyboard.rb, line 49 def object_with_identifier(identifier) @xml.at_xpath("//scene/objects/*[@id='#{identifier}']") end