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



365
366
367
368
369
370
371
372
373
374
375
376
377
# File 'opal/stdlib/native.rb', line 365

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



379
380
381
382
383
384
385
386
387
# File 'opal/stdlib/native.rb', line 379

def to_n
  result = `{}`

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

  result
end