Class: Ovaltine::StoryboardFormatter
- Inherits:
-
Object
- Object
- Ovaltine::StoryboardFormatter
- Defined in:
- lib/ovaltine/objc/storyboard_formatter.rb
Constant Summary collapse
- CELL_REUSE_SECTION_TITLE =
'Cell Reuse Identifiers'- SEGUE_SECTION_TITLE =
'Segue Identifiers'- VIEW_CONTROLLER_SECTION_TITLE =
'View Controllers'
Instance Attribute Summary collapse
-
#classname ⇒ Object
readonly
Returns the value of attribute classname.
-
#storyboard ⇒ Object
readonly
Returns the value of attribute storyboard.
Instance Method Summary collapse
- #copyright_text ⇒ Object
-
#initialize(storyboard, prefix, copyright, output_path) ⇒ StoryboardFormatter
constructor
A new instance of StoryboardFormatter.
- #output_paths ⇒ Object
- #write ⇒ Object
Constructor Details
#initialize(storyboard, prefix, copyright, output_path) ⇒ StoryboardFormatter
Returns a new instance of StoryboardFormatter.
10 11 12 13 14 15 16 17 18 |
# File 'lib/ovaltine/objc/storyboard_formatter.rb', line 10 def initialize storyboard, prefix, copyright, output_path scrubbed_name = storyboard.name.gsub(/\W/,'_') @storyboard = storyboard @prefix = prefix @classname = "#{@prefix}#{scrubbed_name}Storyboard" @copyright = copyright @header_path = File.join(File.(output_path), "#{classname}.h") @impl_path = File.join(File.(output_path), "#{classname}.m") end |
Instance Attribute Details
#classname ⇒ Object (readonly)
Returns the value of attribute classname.
4 5 6 |
# File 'lib/ovaltine/objc/storyboard_formatter.rb', line 4 def classname @classname end |
#storyboard ⇒ Object (readonly)
Returns the value of attribute storyboard.
4 5 6 |
# File 'lib/ovaltine/objc/storyboard_formatter.rb', line 4 def storyboard @storyboard end |
Instance Method Details
#copyright_text ⇒ Object
33 34 35 36 37 38 39 |
# File 'lib/ovaltine/objc/storyboard_formatter.rb', line 33 def copyright_text if @copyright.length > 0 "Copyright (c) #{Time.new.year} #{@copyright}. All rights reserved." else '' end end |
#output_paths ⇒ Object
20 21 22 |
# File 'lib/ovaltine/objc/storyboard_formatter.rb', line 20 def output_paths [@header_path, @impl_path] end |
#write ⇒ Object
24 25 26 27 28 29 30 31 |
# File 'lib/ovaltine/objc/storyboard_formatter.rb', line 24 def write File.open(@header_path, 'w') do |file| file.puts generate_header end File.open(@impl_path, 'w') do |file| file.puts generate_implementation end end |