Class: Mingle::MingleList

Inherits:
MingleValue show all
Extended by:
Forwardable
Includes:
Enumerable
Defined in:
lib/mingle.rb

Instance Method Summary collapse

Constructor Details

#initialize(obj) ⇒ MingleList

Returns a new instance of MingleList.



403
404
405
# File 'lib/mingle.rb', line 403

def initialize( obj )
    @arr = obj.map { |elt| MingleModels.as_mingle_value( elt ) }.freeze
end

Instance Method Details

#+(coll) ⇒ Object



424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
# File 'lib/mingle.rb', line 424

def +( coll )
    
    not_nil( coll, :coll )

    case coll

        when MingleList 
            MingleList.new( @arr + coll.instance_variable_get( :@arr ) )

        when Array then self + MingleList.new( coll )

        else 
            raise "Operation '+' not supported for objects of " \
                  "type #{coll.class}"
    end
end

#==(other) ⇒ Object



418
419
420
421
# File 'lib/mingle.rb', line 418

def ==( other )
    other.is_a?( MingleList ) &&
        other.instance_variable_get( :@arr ) == @arr
end

#to_aObject



413
414
415
# File 'lib/mingle.rb', line 413

def to_a
    Array.new( @arr )
end

#to_sObject



408
409
410
# File 'lib/mingle.rb', line 408

def to_s
    @arr.to_s
end