lib/jini.rb in jini-0.1.2 vs lib/jini.rb in jini-0.1.3

- old
+ new

@@ -20,10 +20,15 @@ # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE # SOFTWARE. +# The jini. +# Author:: Ivan Ivanchuk (clicker.heroes.acg@gmail.com) +# Copyright:: Copyright (c) 2022 Ivan Ivanchuck +# License:: MIT +# # It's a simple XPATH builder. # # require 'jini' # xpath = Jini.new('parent') # .add_node('child') @@ -80,20 +85,27 @@ .join('/') ) end # Addition property in tail. - # Before: '../child' - # After: '../child/property()' + # @example before: '../child', after: '../child/property()' # @param property [String] to add # @return [Jini] with property on tail # @since 0.0.1 def add_property(property) Jini.new(add_node("#{property}()").to_s) end + # Removes property. + # @param property [String] to remove + # @return [Jini] without property on tail + # @since 0.1.3 + def remove_property(property) + Jini.new(@head.gsub("#{property}()", '')) + end + # Additional attribute for xpath. - # '[@key="value"]' + # @example'[@key="value"]' # @param key [String] name of attr # @param value [String] value of attr # @return [Jini] with additional attr on tail def add_attr(key, value) Jini.new("#{@head}[@#{key}=\"#{value}\"]")