Browse Source

Actually document the Regexp support for #[].

Douglas Thrift 7 years ago
parent
commit
c226751687
3 changed files with 9 additions and 6 deletions
  1. 1 0
      README.md
  2. 7 5
      lib/machine_tag/set.rb
  3. 1 1
      lib/machine_tag/version.rb

+ 1 - 0
README.md

@@ -74,6 +74,7 @@ tags.machine_tags           # => #<Set: {"geo:lat=34.4348067", "geo:lon=-119.801
 tags['geo']                 # => #<Set: {"geo:lat=34.4348067", "geo:lon=-119.8016962"}>
 tags['geo:lat']             # => #<Set: {"geo:lat=34.4348067"}>
 tags['geo', 'lon']          # => #<Set: {"geo:lon=-119.8016962"}>
+tags[/^geo:(lat|lon)$/]     # => #<Set: {"geo:lat=34.4348067", "geo:lon=-119.8016962"}>
 ```
 
 More information can be found in the [documentation].

+ 7 - 5
lib/machine_tag/set.rb

@@ -81,13 +81,15 @@ module MachineTag
     #
     # @example
     #   tags = MachineTag::Set['a:b=x', 'a:b=y', 'a:c=z']
-    #   tags['a']       # => #<Set: {"a:b=x", "a:b=y", "a:c=z"}>
-    #   tags['a', 'b']  # => #<Set: {"a:b=x", "a:b=y"}>
-    #   tags['a:c']     # => #<Set: {"a:c=z"}>
+    #   tags['a']           # => #<Set: {"a:b=x", "a:b=y", "a:c=z"}>
+    #   tags['a', 'b']      # => #<Set: {"a:b=x", "a:b=y"}>
+    #   tags['a:c']         # => #<Set: {"a:c=z"}>
+    #   tags['a', /^[bc]$/] # => #<Set: {"a:b=x", "a:b=y", "a:c=z"}>
+    #   tags[/^a:[bc]$/]    # => #<Set: {"a:b=x", "a:b=y", "a:c=z"}>
     #
-    # @param namespace_or_namespace_and_predicate [String] the namespace to retrieve or the namespace
+    # @param namespace_or_namespace_and_predicate [String, Regexp] the namespace to retrieve or the namespace
     #   and predicate to retreive combined in a string separated by +':'+
-    # @param predicate [String, nil] the predicate to retreive
+    # @param predicate [String, Regexp, nil] the predicate to retreive
     #
     # @return [::Set<Tag>] the machines tags that have the given namespace or namespace and predicate
     #

+ 1 - 1
lib/machine_tag/version.rb

@@ -26,5 +26,5 @@
 module MachineTag
   # The version of this library.
   #
-  VERSION = "1.1.0"
+  VERSION = "1.1.1"
 end