Class: Property
- Inherits:
-
Object
- Object
- Property
- Defined in:
- lib/swift_republic.rb
Instance Attribute Summary collapse
-
#associated_struct ⇒ Object
Returns the value of attribute associated_struct.
-
#declaration_String ⇒ Object
Returns the value of attribute declaration_String.
-
#leading_spaces_count ⇒ Object
Returns the value of attribute leading_spaces_count.
-
#name ⇒ Object
Returns the value of attribute name.
-
#type ⇒ Object
Returns the value of attribute type.
Instance Method Summary collapse
-
#initialize(struct, declaration_String) ⇒ Property
constructor
A new instance of Property.
Constructor Details
#initialize(struct, declaration_String) ⇒ Property
Returns a new instance of Property.
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/swift_republic.rb', line 9 def initialize(struct, declaration_String) @associated_struct = struct indent_offset = declaration_String =~ /\S/ # Any non-whitespace character @leading_spaces_count = indent_offset @declaration_String = declaration_String.strip # Eg. "var sourceOfIncome: String" if declaration_String.include? ":" arr = declaration_String.split(":") name = arr.first.split(" ").last @name = name right_of_first_colon = arr.drop(1).join(":").strip @type = right_of_first_colon.split("//").first.strip else @name = "" @type = "" p "Inferred types cannot be handled by the script --> #{declaration_String}" end end |
Instance Attribute Details
#associated_struct ⇒ Object
Returns the value of attribute associated_struct.
6 7 8 |
# File 'lib/swift_republic.rb', line 6 def associated_struct @associated_struct end |
#declaration_String ⇒ Object
Returns the value of attribute declaration_String.
6 7 8 |
# File 'lib/swift_republic.rb', line 6 def declaration_String @declaration_String end |
#leading_spaces_count ⇒ Object
Returns the value of attribute leading_spaces_count.
7 8 9 |
# File 'lib/swift_republic.rb', line 7 def leading_spaces_count @leading_spaces_count end |
#name ⇒ Object
Returns the value of attribute name.
7 8 9 |
# File 'lib/swift_republic.rb', line 7 def name @name end |
#type ⇒ Object
Returns the value of attribute type.
7 8 9 |
# File 'lib/swift_republic.rb', line 7 def type @type end |