Class: Vertx::MultiMap
- Inherits:
-
Object
- Object
- Vertx::MultiMap
- Defined in:
- lib/vertx/http.rb
Overview
A map which can hold multiple values for one name / key
Instance Method Summary collapse
-
#[](name) ⇒ Object
Returns the value of with the specified name.
-
#[]=(name, value) ⇒ Object
Set a value with the specified name and value.
- #_j_map ⇒ Object
-
#add(name, value) ⇒ Object
Adds a new value with the specified name and value.
-
#clear ⇒ Object
Remove all entries.
-
#contains(name) ⇒ Object
Returns true if an entry with the given name was found.
-
#each(&hndlr) ⇒ Object
Call the handler for each header name and its value.
-
#empty? ⇒ Boolean
Returns true if the map is empty.
-
#get(name) ⇒ Object
Returns the value of with the specified name.
-
#get_all(name) ⇒ Array
Returns the values with the specified name.
-
#initialize(j_map) ⇒ MultiMap
constructor
A new instance of MultiMap.
-
#names ⇒ Set
Return a Set which holds all names of the entries.
-
#remove(name) ⇒ Object
Remove the values with the given name.
-
#set(name, value) ⇒ Object
Set a value with the specified name and value.
-
#set_all(map) ⇒ Object
Set a value with the specified name and value.
-
#size ⇒ Object
Return the number of names in this instance.
Constructor Details
#initialize(j_map) ⇒ MultiMap
Returns a new instance of MultiMap.
549 550 551 |
# File 'lib/vertx/http.rb', line 549 def initialize(j_map) @j_map = j_map end |
Instance Method Details
#[](name) ⇒ Object
Returns the value of with the specified name. If there are more than one values for the specified name, the first value is returned.
579 580 581 |
# File 'lib/vertx/http.rb', line 579 def [](name) @j_map.get(name) end |
#[]=(name, value) ⇒ Object
Set a value with the specified name and value.
589 590 591 592 |
# File 'lib/vertx/http.rb', line 589 def []=(name, value) @j_map.set(name, value) self end |
#_j_map ⇒ Object
673 674 675 |
# File 'lib/vertx/http.rb', line 673 def _j_map @j_map end |
#add(name, value) ⇒ Object
Adds a new value with the specified name and value.
626 627 628 629 |
# File 'lib/vertx/http.rb', line 626 def add(name, value) @j_map.add(name, value) self end |
#clear ⇒ Object
Remove all entries
663 664 665 666 |
# File 'lib/vertx/http.rb', line 663 def clear @j_map.clear() self end |
#contains(name) ⇒ Object
Returns true if an entry with the given name was found
604 605 606 |
# File 'lib/vertx/http.rb', line 604 def contains(name) @j_map.contains(name) end |
#each(&hndlr) ⇒ Object
Call the handler for each header name and its value. If there are multiple values are stored for a header name it will be called for each of them
556 557 558 559 560 561 562 563 |
# File 'lib/vertx/http.rb', line 556 def each(&hndlr) names.each do |name| values = @j_map.getAll(name) for v in values hndlr.call(name, v) end end end |
#empty? ⇒ Boolean
Returns true if the map is empty
609 610 611 |
# File 'lib/vertx/http.rb', line 609 def empty? @j_map.isEmpty() end |
#get(name) ⇒ Object
Returns the value of with the specified name. If there are more than one values for the specified name, the first value is returned.
570 571 572 |
# File 'lib/vertx/http.rb', line 570 def get(name) @j_map.get(name) end |
#get_all(name) ⇒ Array
Returns the values with the specified name
599 600 601 |
# File 'lib/vertx/http.rb', line 599 def get_all(name) @j_map.getAll(name).to_a end |
#names ⇒ Set
Return a Set which holds all names of the entries
616 617 618 |
# File 'lib/vertx/http.rb', line 616 def names @j_map.names() end |
#remove(name) ⇒ Object
Remove the values with the given name
655 656 657 658 |
# File 'lib/vertx/http.rb', line 655 def remove(name) @j_map.remove(name) self end |
#set(name, value) ⇒ Object
Set a value with the specified name and value.
636 637 638 639 |
# File 'lib/vertx/http.rb', line 636 def set(name, value) @j_map.set(name, value) self end |
#set_all(map) ⇒ Object
Set a value with the specified name and value.
646 647 648 649 |
# File 'lib/vertx/http.rb', line 646 def set_all(map) @j_map.set(map._j_map) self end |
#size ⇒ Object
Return the number of names in this instance
669 670 671 |
# File 'lib/vertx/http.rb', line 669 def size @j_map.size() end |