Class: Quark::Quark::URL

Inherits:
DatawireQuarkCore::QuarkObject show all
Extended by:
DatawireQuarkCore::Static
Defined in:
lib/quark.rb

Overview

A URL class.

Constant Summary

Constants included from DatawireQuarkCore::Static

DatawireQuarkCore::Static::Unassigned

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from DatawireQuarkCore::Static

_lazy_statics, static, unlazy_statics

Methods inherited from DatawireQuarkCore::QuarkObject

#to_s

Constructor Details

#initializeURL

Returns a new instance of URL.



2431
2432
2433
2434
2435
# File 'lib/quark.rb', line 2431

def initialize()
    self.__init_fields__

    nil
end

Instance Attribute Details

#hostObject

Returns the value of attribute host.



2424
2425
2426
# File 'lib/quark.rb', line 2424

def host
  @host
end

#pathObject

Returns the value of attribute path.



2424
2425
2426
# File 'lib/quark.rb', line 2424

def path
  @path
end

#portObject

Returns the value of attribute port.



2424
2425
2426
# File 'lib/quark.rb', line 2424

def port
  @port
end

#schemeObject

Returns the value of attribute scheme.



2424
2425
2426
# File 'lib/quark.rb', line 2424

def scheme
  @scheme
end

Class Method Details

.parse(url) ⇒ Object



2440
2441
2442
2443
2444
2445
2446
2447
2448
2449
2450
2451
2452
2453
2454
2455
2456
2457
2458
2459
2460
2461
2462
2463
2464
2465
2466
2467
2468
2469
2470
2471
2472
2473
2474
2475
2476
2477
2478
2479
# File 'lib/quark.rb', line 2440

def self.parse(url)
    
    result = ::Quark.quark.URL.new()
    if ((url) == (nil))
        return ::DatawireQuarkCore.cast(nil) { ::Quark.quark.URL }
    end
    parts = nil
    remaining = nil
    idx = ((url).index("://") or -1)
    if ((idx) >= (0))
        (result).scheme = (url)[(0)...(idx)]
        remaining = (url)[((idx) + (3))...((url).size)]
    else
        remaining = url
    end
    firstSlash = ((remaining).index("/") or -1)
    if ((firstSlash) == (0))
        (result).path = remaining
        return result
    end
    if ((firstSlash) < (0))
        firstSlash = (remaining).size
    else
        (result).path = (remaining)[(firstSlash)...((remaining).size)]
    end
    idx = ((remaining).index(":") or -1)
    if ((idx) > (firstSlash))
        (result).host = (remaining)[(0)...(firstSlash)]
    else
        if ((idx) >= (0))
            (result).host = (remaining)[(0)...(idx)]
            (result).port = (remaining)[((idx) + (1))...(firstSlash)]
        else
            (result).host = (remaining)[(0)...(firstSlash)]
        end
    end
    return result

    nil
end

Instance Method Details

#__init_fields__Object



2545
2546
2547
2548
2549
2550
2551
2552
2553
# File 'lib/quark.rb', line 2545

def __init_fields__()
    
    self.scheme = nil
    self.host = nil
    self.port = nil
    self.path = nil

    nil
end

#_getClassObject



2501
2502
2503
2504
2505
2506
# File 'lib/quark.rb', line 2501

def _getClass()
    
    return "quark.URL"

    nil
end

#_getField(name) ⇒ Object



2508
2509
2510
2511
2512
2513
2514
2515
2516
2517
2518
2519
2520
2521
2522
2523
2524
2525
# File 'lib/quark.rb', line 2508

def _getField(name)
    
    if ((name) == ("scheme"))
        return (self).scheme
    end
    if ((name) == ("host"))
        return (self).host
    end
    if ((name) == ("port"))
        return (self).port
    end
    if ((name) == ("path"))
        return (self).path
    end
    return nil

    nil
end

#_setField(name, value) ⇒ Object



2527
2528
2529
2530
2531
2532
2533
2534
2535
2536
2537
2538
2539
2540
2541
2542
2543
# File 'lib/quark.rb', line 2527

def _setField(name, value)
    
    if ((name) == ("scheme"))
        (self).scheme = ::DatawireQuarkCore.cast(value) { ::String }
    end
    if ((name) == ("host"))
        (self).host = ::DatawireQuarkCore.cast(value) { ::String }
    end
    if ((name) == ("port"))
        (self).port = ::DatawireQuarkCore.cast(value) { ::String }
    end
    if ((name) == ("path"))
        (self).path = ::DatawireQuarkCore.cast(value) { ::String }
    end

    nil
end

#toStringObject



2481
2482
2483
2484
2485
2486
2487
2488
2489
2490
2491
2492
2493
2494
2495
2496
2497
2498
2499
# File 'lib/quark.rb', line 2481

def toString()
    
    result = ""
    if ((@scheme) != (nil))
        result = (@scheme) + ("://")
    end
    if ((@host) != (nil))
        result = (result) + (@host)
    end
    if ((@port) != (nil))
        result = ((result) + (":")) + (@port)
    end
    if ((@path) != (nil))
        result = (result) + (@path)
    end
    return result

    nil
end