lib/jini.rb in jini-0.0.3 vs lib/jini.rb in jini-0.0.4
- old
+ new
@@ -14,11 +14,11 @@
# The above copyright notice and this permission notice shall be included in all
# copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+# FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE
# 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.
@@ -30,11 +30,11 @@
# .to_s // /body/child/child
class Jini
# When path not valid
class InvalidPath < StandardError; end
- # @param head [String] with head of your xpath
+ # @param head [String]
def initialize(head = '')
@head = head
end
# Convert it to a string.
@@ -49,11 +49,11 @@
def add_path(node)
Jini.new("#{@head}/#{node}")
end
# Additional attribute for xpath.
- # [@key="value"]
+ # '[@key="value"]'
# @param key [String] name of attr
# @param value [String] value of attr
# @return [Jini] object
def add_attr(key, value)
Jini.new("#{@head}[@#{key}=\"#{value}\"]")
@@ -65,34 +65,34 @@
def all_attr(value)
Jini.new("#{@head}@#{value}")
end
# Xpath with all elements.
- # Addition a *** to xpath
+ # Addition an '*' to tail of xpath
# @return [Jini] object
def all
raise InvalidPath, 'You cannot add all tag after attr!' if @head[-1].eql?(']')
- Jini.new(add_path('*').to_s) unless @head[-1].eql?(']')
+ Jini.new(add_path('*').to_s)
end
# Xpath with all named elements.
- # Addition _//node_ to xpath
+ # Addition '//node' to xpath
# @param node [String] name of node
# @return [Jini] object
def add_all(node)
Jini.new("#{@head}//#{node}")
end
# Access by index.
- # Addition _[index]_ to xpath
+ # Addition '[index]' to xpath
# @param position [Integer] number
# @return [Jini] object
def at(position)
Jini.new("#{@head}[#{position}]")
end
- # Replace all _/_ to _::_ symbols
+ # Replace all '/' to '::' symbols
# if path doesn't contain invalid symbols for selection
# @return [Jini] selection
def selection
if @head.include?('[') || @head.include?(']') || @head.include?('@')
raise InvalidPath, 'Cannot select, path contains bad symbols'
@@ -107,13 +107,12 @@
Jini.new(@head.gsub("/#{node}", ''))
end
# Removes attr by name
# before:
- # `/parent/child[@k="v"]`
- # .remove_attr('k')
+ # '/parent/child[@k="v"]'
# after:
- # `/parent/child`
+ # '/parent/child'
# @param [String] name of attr
# @return [Jini] without an attr
def remove_attr(name)
Jini.new(
@head