Class: Quark::Quark::URL
- Inherits:
-
DatawireQuarkCore::QuarkObject
- Object
- DatawireQuarkCore::QuarkObject
- Quark::Quark::URL
- 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
-
#host ⇒ Object
Returns the value of attribute host.
-
#path ⇒ Object
Returns the value of attribute path.
-
#port ⇒ Object
Returns the value of attribute port.
-
#scheme ⇒ Object
Returns the value of attribute scheme.
Class Method Summary collapse
Instance Method Summary collapse
- #__init_fields__ ⇒ Object
- #_getClass ⇒ Object
- #_getField(name) ⇒ Object
- #_setField(name, value) ⇒ Object
-
#initialize ⇒ URL
constructor
A new instance of URL.
- #toString ⇒ Object
Methods included from DatawireQuarkCore::Static
_lazy_statics, static, unlazy_statics
Methods inherited from DatawireQuarkCore::QuarkObject
Constructor Details
#initialize ⇒ URL
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
#host ⇒ Object
Returns the value of attribute host.
2424 2425 2426 |
# File 'lib/quark.rb', line 2424 def host @host end |
#path ⇒ Object
Returns the value of attribute path.
2424 2425 2426 |
# File 'lib/quark.rb', line 2424 def path @path end |
#port ⇒ Object
Returns the value of attribute port.
2424 2425 2426 |
# File 'lib/quark.rb', line 2424 def port @port end |
#scheme ⇒ Object
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 |
#_getClass ⇒ Object
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 |
#toString ⇒ Object
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 |