Class: Struct

Inherits:
Object show all
Defined in:
opal/stdlib/native.rb

Instance Method Summary collapse

Constructor Details

#initialize(*args) ⇒ Struct

Returns a new instance of Struct



393
394
395
396
397
398
399
400
401
402
403
404
405
# File 'opal/stdlib/native.rb', line 393

def initialize(*args)
  if args.length == 1 && native?(args[0])
    object = args[0]

    members.each {|name|
      instance_variable_set "@#{name}", Native(`#{object}[#{name}]`)
    }
  else
    members.each_with_index {|name, index|
      instance_variable_set "@#{name}", args[index]
    }
  end
end

Instance Method Details

#to_nObject



407
408
409
410
411
412
413
414
415
# File 'opal/stdlib/native.rb', line 407

def to_n
  result = `{}`

  each_pair {|name, value|
    `#{result}[#{name}] = #{value.to_n}`
  }

  result
end