Class: Struct
Instance Method Summary collapse
-
#initialize(*args) ⇒ Struct
constructor
A new instance of Struct.
- #to_n ⇒ Object
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_n ⇒ Object
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 |