Class: Jaspion::Kilza::Swift::Property
- Defined in:
- lib/jaspion/kilza/language/swift/property.rb
Instance Attribute Summary
Attributes inherited from Property
#array, #key, #name, #original_name, #original_type, #type
Instance Method Summary collapse
- #class_name ⇒ Object
- #constants(cl_name) ⇒ Object
- #declaration ⇒ Object
-
#initialize(name, type, array, key = '') ⇒ Property
constructor
A new instance of Property.
Methods inherited from Property
#==, #boolean?, clean, #fixnum?, #float?, normalize, #null?, #object?, #to_s
Constructor Details
#initialize(name, type, array, key = '') ⇒ Property
Returns a new instance of Property.
8 9 10 11 12 13 14 15 |
# File 'lib/jaspion/kilza/language/swift/property.rb', line 8 def initialize(name, type, array, key = '') original_name = name unless RESERVED_WORDS.index(name.downcase).nil? name = RESERVED_PROPERTY_PREFIX + name end super(name, type, array, key) @original_name = original_name end |
Instance Method Details
#class_name ⇒ Object
17 18 19 20 21 22 23 |
# File 'lib/jaspion/kilza/language/swift/property.rb', line 17 def class_name return if !(object? || null? || (array? && null?)) class_name = super class_name = class_name + RESERVED_CLASS_POSFIX unless RESERVED_WORDS.index(class_name.downcase).nil? class_name end |
#constants(cl_name) ⇒ Object
25 26 27 |
# File 'lib/jaspion/kilza/language/swift/property.rb', line 25 def constants(cl_name) " static let k#{cl_name}#{@name.capitalize}: String = \"#{@original_name.gsub('"', '\"')}\"" end |
#declaration ⇒ Object
29 30 31 |
# File 'lib/jaspion/kilza/language/swift/property.rb', line 29 def declaration " public var #{@name}: #{@type}?" end |