Class: RestKat::ObjCClass

Inherits:
Object
  • Object
show all
Defined in:
lib/rest_kat.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(type, json_type, node) ⇒ ObjCClass

Returns a new instance of ObjCClass.



136
137
138
139
140
141
# File 'lib/rest_kat.rb', line 136

def initialize type, json_type, node
  self.properties = nil
  self.type = type
  self.json_type = json_type
  self.node = node
end

Instance Attribute Details

#json_typeObject

Returns the value of attribute json_type.



86
87
88
# File 'lib/rest_kat.rb', line 86

def json_type
  @json_type
end

#nodeObject

Returns the value of attribute node.



87
88
89
# File 'lib/rest_kat.rb', line 87

def node
  @node
end

#parentObject

Returns the value of attribute parent.



85
86
87
# File 'lib/rest_kat.rb', line 85

def parent
  @parent
end

#propertiesObject

Returns the value of attribute properties.



82
83
84
# File 'lib/rest_kat.rb', line 82

def properties
  @properties
end

#resourceObject

Returns the value of attribute resource.



88
89
90
# File 'lib/rest_kat.rb', line 88

def resource
  @resource
end

#sequence_ofObject

Returns the value of attribute sequence_of.



83
84
85
# File 'lib/rest_kat.rb', line 83

def sequence_of
  @sequence_of
end

#typeObject

Returns the value of attribute type.



84
85
86
# File 'lib/rest_kat.rb', line 84

def type
  @type
end

Instance Method Details

#complex?Boolean

Returns:

  • (Boolean)


98
99
100
# File 'lib/rest_kat.rb', line 98

def complex?
  map? || seq?
end

#enumObject



118
119
120
# File 'lib/rest_kat.rb', line 118

def enum
  node["enum"]
end

#enum?Boolean

Returns:

  • (Boolean)


114
115
116
# File 'lib/rest_kat.rb', line 114

def enum?
  (node["type"] == "str") && node.has_key?("enum")
end

#map?Boolean

Returns:

  • (Boolean)


102
103
104
# File 'lib/rest_kat.rb', line 102

def map?
  properties && (not properties.empty?)
end

#objc_classObject



110
111
112
# File 'lib/rest_kat.rb', line 110

def objc_class
  self.type
end

#objc_properites_arg_list_declObject



130
131
132
133
134
# File 'lib/rest_kat.rb', line 130

def objc_properites_arg_list_decl
  properties.reject{|p| p.name == 'id'}.map do |p|
    p.klass.objc_property_arg_decl p.name
  end.join "\n   "
end

#objc_property_arg_decl(name) ⇒ Object



126
127
128
# File 'lib/rest_kat.rb', line 126

def objc_property_arg_decl name
  "#{name}: (#{objc_class} *) #{name}"
end

#objc_property_decl(name) ⇒ Object



122
123
124
# File 'lib/rest_kat.rb', line 122

def objc_property_decl name
  "@property (nonatomic, strong) #{objc_class} * #{name}"
end

#objc_super_classObject



90
91
92
93
94
95
96
# File 'lib/rest_kat.rb', line 90

def objc_super_class
  if resource
    "MSRestSerializableResource"
  else
    "MSRestSerializable"
  end
end

#seq?Boolean

Returns:

  • (Boolean)


106
107
108
# File 'lib/rest_kat.rb', line 106

def seq?
  !!sequence_of
end