Class: Attribute

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, type, is_array = false) ⇒ Attribute

Returns a new instance of Attribute.



252
253
254
255
256
# File 'lib/parser.rb', line 252

def initialize name, type, is_array=false
  @name = name
  @type = type
  @is_array = is_array
end

Instance Attribute Details

#is_arrayObject

Returns the value of attribute is_array.



251
252
253
# File 'lib/parser.rb', line 251

def is_array
  @is_array
end

#nameObject

Returns the value of attribute name.



251
252
253
# File 'lib/parser.rb', line 251

def name
  @name
end

#typeObject

Returns the value of attribute type.



251
252
253
# File 'lib/parser.rb', line 251

def type
  @type
end

Instance Method Details

#default_valueObject



258
259
260
261
262
263
264
265
266
267
268
269
270
271
# File 'lib/parser.rb', line 258

def default_value
  result = nil
  case @type
  when "String"
    result = "\"\""
  when "Int"
    result = 0
  when "Double"
    result = 0.0
  when "Bool"
    result = false
  end
  result
end