Class: Spectra::ObjcCategory
- Defined in:
- lib/spectra/views/objc_category.rb
Instance Attribute Summary collapse
-
#is_header ⇒ Object
Returns the value of attribute is_header.
Attributes inherited from View
Attributes included from Serializable
Class Method Summary collapse
Instance Method Summary collapse
-
#class_prefix ⇒ Object
Templating.
- #file_extension ⇒ Object
- #file_keyword ⇒ Object
-
#filename ⇒ Object
Pathing Hooks.
-
#format_color_value(value) ⇒ Object
Formatting.
-
#initialize(attributes) ⇒ ObjcCategory
constructor
A new instance of ObjcCategory.
- #renamer ⇒ Object
- #whitespace ⇒ Object
Methods inherited from View
#format_color_name, #render, template_name, #to_s, #views_from_colors
Methods included from Serializable
#destination, #serialize, #write_file
Constructor Details
#initialize(attributes) ⇒ ObjcCategory
Returns a new instance of ObjcCategory.
14 15 16 17 |
# File 'lib/spectra/views/objc_category.rb', line 14 def initialize(attributes) super self.is_header = attributes[:is_header] end |
Instance Attribute Details
#is_header ⇒ Object
Returns the value of attribute is_header.
8 9 10 |
# File 'lib/spectra/views/objc_category.rb', line 8 def is_header @is_header end |
Class Method Details
.from_attributes(attributes) ⇒ Object
10 11 12 |
# File 'lib/spectra/views/objc_category.rb', line 10 def self.from_attributes(attributes) [ self.new(attributes.merge(is_header: true)), self.new(attributes) ] end |
Instance Method Details
#class_prefix ⇒ Object
Templating
23 24 25 |
# File 'lib/spectra/views/objc_category.rb', line 23 def class_prefix self.prefix.upcase end |
#file_extension ⇒ Object
31 32 33 |
# File 'lib/spectra/views/objc_category.rb', line 31 def file_extension self.is_header ? 'h' : 'm' end |
#file_keyword ⇒ Object
27 28 29 |
# File 'lib/spectra/views/objc_category.rb', line 27 def file_keyword self.is_header ? "interface" : "implementation" end |
#filename ⇒ Object
Pathing Hooks
55 56 57 |
# File 'lib/spectra/views/objc_category.rb', line 55 def filename super || "UIColor+#{self.class_prefix}Color.#{self.file_extension}" end |
#format_color_value(value) ⇒ Object
Formatting
43 44 45 |
# File 'lib/spectra/views/objc_category.rb', line 43 def format_color_value(value) '%.2f' % (value || 0.0) + 'f' end |
#renamer ⇒ Object
47 48 49 |
# File 'lib/spectra/views/objc_category.rb', line 47 def renamer @renamer ||= lambda { |color, prefix| "#{prefix}_#{color.name.camelize(false)}Color#{color.suffix}" } end |
#whitespace ⇒ Object
35 36 37 |
# File 'lib/spectra/views/objc_category.rb', line 35 def whitespace self.is_header ? "\n" : '' end |