Class: Nidyx::ObjCProperty

Inherits:
Object
  • Object
show all
Includes:
ObjCConstants
Defined in:
lib/nidyx/objc/property.rb

Defined Under Namespace

Classes: UnsupportedEnumTypeError

Constant Summary

Constants included from ObjCConstants

Nidyx::ObjCConstants::ATTRIBUTES, Nidyx::ObjCConstants::BOXABLE_NUMBERS, Nidyx::ObjCConstants::ENUM_TYPES, Nidyx::ObjCConstants::FORBIDDEN_PROPERTY_PREFIXES, Nidyx::ObjCConstants::OBJECTS, Nidyx::ObjCConstants::OBJECT_ATTRIBUTES, Nidyx::ObjCConstants::PRIMITIVE_ATTRIBUTES, Nidyx::ObjCConstants::SIMPLE_NUMBERS, Nidyx::ObjCConstants::TYPES

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(property) ⇒ ObjCProperty

Returns a new instance of ObjCProperty.

Parameters:

  • property (Property)

    generic property



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/nidyx/objc/property.rb', line 16

def initialize(property)
  @name = property.name
  @optional = property.optional
  @desc = property.description

  @getter_override = process_getter_override(name)
  @type = process_type(property)
  @attributes = ATTRIBUTES[@type]
  @type_name = lookup_type_name(@type, property.class_name)

  @protocols = []
  # Exclude any standard objc types from the protocols
  @protocols += Nidyx::ObjCUtils.filter_standard_types(property.collection_types) if property.collection_types
  @protocols << "Optional" if @optional
end

Instance Attribute Details

#attributesObject (readonly)

Returns the value of attribute attributes.



12
13
14
# File 'lib/nidyx/objc/property.rb', line 12

def attributes
  @attributes
end

#descObject (readonly)

Returns the value of attribute desc.



12
13
14
# File 'lib/nidyx/objc/property.rb', line 12

def desc
  @desc
end

#getter_overrideObject (readonly)

Returns the value of attribute getter_override.



12
13
14
# File 'lib/nidyx/objc/property.rb', line 12

def getter_override
  @getter_override
end

#nameObject (readonly)

Returns the value of attribute name.



12
13
14
# File 'lib/nidyx/objc/property.rb', line 12

def name
  @name
end

#protocolsObject (readonly)

Returns the value of attribute protocols.



12
13
14
# File 'lib/nidyx/objc/property.rb', line 12

def protocols
  @protocols
end

#typeObject (readonly)

Returns the value of attribute type.



12
13
14
# File 'lib/nidyx/objc/property.rb', line 12

def type
  @type
end

#type_nameObject (readonly)

Returns the value of attribute type_name.



12
13
14
# File 'lib/nidyx/objc/property.rb', line 12

def type_name
  @type_name
end

Instance Method Details

#has_protocols?Boolean

Returns true if the property has protocols.

Returns:

  • (Boolean)

    true if the property has protocols



38
39
40
# File 'lib/nidyx/objc/property.rb', line 38

def has_protocols?
  !@protocols.empty?
end

#is_obj?Boolean

Returns true if the obj-c property type is an object.

Returns:

  • (Boolean)

    true if the obj-c property type is an object



33
34
35
# File 'lib/nidyx/objc/property.rb', line 33

def is_obj?
  OBJECTS.include?(self.type)
end

#protocols_stringString

Returns the property’s protocols, comma separated.

Returns:

  • (String)

    the property’s protocols, comma separated



43
44
45
# File 'lib/nidyx/objc/property.rb', line 43

def protocols_string
  @protocols.join(", ")
end