{!: rooto:"YARD::CodeObjects::RootObject:@childrenIC:&YARD::CodeObjects::CodeObjectList[o:#YARD::CodeObjects::ClassObject;IC;[o; ;IC;[: @owner@ :@class_mixinsIC;[; @ :@instance_mixinsIC;[; @ :@attributesIC:SymbolHash{: classIC;{:@symbolize_valueT: instanceIC;{;T;T: @aliases{: @groups[: @files[[I"lib/jini.rb:ETi.:@current_file_has_commentsT: @name:InvalidPath:@source_type: ruby:@visibility: public: @tags[:@docstrings{:@docstringIC:YARD::Docstring"When path not valid;T;[:@ref_tags[: @allI"When path not valid;T:@unresolved_reference0: @object@ :@hash_flagF:@line_rangeo: Range: exclF: begini-:endi-:@ref_tag_recurse_counti:@namespace@: @pathI"Jini::InvalidPath;F:@superclasso:YARD::CodeObjects::Proxy :@orignamespace0:@origname0: @imethod0;:StandardError;,@: @obj0: @type;: @dynamicTo:$YARD::CodeObjects::MethodObject:@module_functionF: @scope;;;;-I"Jini#initialize;F:@parameters[[I" head;TI"'';T;[[@i4;T;:initialize;;;[;{;IC; "aMakes new object. By default it creates an empty path and you can ignore the head parameter.;T;[o:YARD::Tags::Tag :@tag_nameI" param;F: @textI";T;I" head;T: @types[I" String;T;$@o;< ;=I" since;F;>I" 0.0.1;T;0;?0;$@o;< ;=I" return;F;>I"a new instance of Jini;T;0;?[I" Jini;F;$@;![;"I"~Makes new object. By default it creates an empty path and you can ignore the head parameter. @param head [String] @since 0.0.1;T;#0;$@;%F;&o;';(F;)i0;*i3;+i;,@:@explicitT: @sourceI"1def initialize(head = '') @head = head end;T:@signatureI"def initialize(head = '');T;6To;7;8F;9;;;;-I"Jini#to_s;F;:[;[[@i<;T;: to_s;;;[;{;IC; "Convert it to a string.;T;[o;< ;=I" return;F;>I"xpath as string;T;0;?[I" String;T;$@>o;< ;=I" raise;F;>I"&if contain spaces in simple nodes;T;0;?[I"InvalidPath;T;$@>o;< ;=I" since;F;>I" 0.0.1;T;0;?0;$@>;![;"I"|Convert it to a string. @return [String] xpath as string @raise [InvalidPath] if contain spaces in simple nodes @since 0.0.1;T;#0;$@>;%F;&o;';(F;)i8;*i;;+i;,@;@T;AI"`def to_s copy = @head.split(%r{//|/}) copy.each(&method(:space_check)) @head.to_s end;T;BI" def to_s;T;6To;7;8F;9;;;;-I"Jini#add_node;F;:[[I" node;T0;[[@iF;T;: add_node;;;[;{;IC; "Additional node for xpath.;T;[o;< ;=I" param;F;>I" the node;T;I" node;T;?[I" String;T;$@Yo;< ;=I" return;F;>I" object with additional node;T;0;?[I" Jini;T;$@Yo;< ;=I" since;F;>I" 0.0.1;T;0;?0;$@Y;![;"I"uAdditional node for xpath. @param node [String] the node @return [Jini] object with additional node @since 0.0.1;T;#0;$@Y;%F;&o;';(F;)iB;*iE;+i;,@;@T;AI":def add_node(node) Jini.new("#{@head}/#{node}") end;T;BI"def add_node(node);T;6To;7;8F;9;;;;-I"Jini#remove_node;F;:[[I" node;T0;[[@iN;T;:remove_node;;;[;{;IC; "Removes node by name.;T;[o;< ;=I" param;F;>I"the node for removal;T;I" node;T;?[I" String;T;$@wo;< ;=I" return;F;>I"without a node;T;0;?[I" Jini;T;$@wo;< ;=I" since;F;>I" 0.0.7;T;0;?0;$@w;![;"I"oRemoves node by name. @param node [String] the node for removal @return [Jini] without a node @since 0.0.7;T;#0;$@w;%F;&o;';(F;)iJ;*iM;+i;,@;@T;AI"Adef remove_node(node) Jini.new(purge_head("/#{node}")) end;T;BI"def remove_node(node);T;6To;7;8F;9;;;;-I"Jini#replace_node;F;:[[I" origin;T0[I"new;T0;[[@iV;T;:replace_node;;;[;{;IC; "/This method replaces *all* origins to new.;T;[o;< ;=I" param;F;>I"origin node;T;I" origin;T;?[I" String;T;$@o;< ;=I" param;F;>I" new one;T;I"new;T;?[I" String;T;$@o;< ;=I" since;F;>I" 0.1.0;T;0;?0;$@;![;"I"{This method replaces *all* origins to new. @param origin [String] origin node @param new [String] new one @since 0.1.0;T;#0;$@;%F;&o;';(F;)iR;*iU;+i;,@;@T;AI"def replace_node(origin, new) Jini.new( @head .split('/') .map! { |node| node.eql?(origin) ? new : node } .join('/') ) end;T;BI""def replace_node(origin, new);T;6To;7;8F;9;;;;-I"Jini#nodes;F;:[;[[@ia;T;: nodes;;;[;{;IC; "!All nodes in xpath as array.;T;[o;< ;=I" return;F;>I"nodes as [Array];T;0;?0;$@;![;"I":All nodes in xpath as array. @return nodes as [Array];T;#0;$@;%F;&o;';(F;)i_;*i`;+i;,@;@T;AI"def nodes checked = @head .split(%r{(//|/)}) .each(&method(:empty_check)) checked.each { |node| checked.delete node if node.eql?('//') || node.eql?('/') }.to_a end;T;BI"def nodes;T;6To;7;8F;9;;;;-I"Jini#add_property;F;:[[I" property;T0;[[@im;T;:add_property;;;[;{;IC; "Addition property in tail.;T;[ o;< ;=I" example;F;>I";F;I"5before: '../child', after: '../child/property()';T;?0;$@o;< ;=I" param;F;>I" to add;T;I" property;T;?[I" String;T;$@o;< ;=I" return;F;>I"with property on tail;T;0;?[I" Jini;T;$@o;< ;=I" since;F;>I" 0.0.1;T;0;?0;$@;![;"I"Addition property in tail. @example before: '../child', after: '../child/property()' @param property [String] to add @return [Jini] with property on tail @since 0.0.1;T;#0;$@;%F;&o;';(F;)ih;*il;+i;,@;@T;AI"Ndef add_property(property) Jini.new(add_node("#{property}()").to_s) end;T;BI"def add_property(property);T;6To;7;8F;9;;;;-I"Jini#remove_property;F;:[[I" property;T0;[[@iu;T;:remove_property;;;[;{;IC; "Removes property.;T;[o;< ;=I" param;F;>I"to remove;T;I" property;T;?[I" String;T;$@o;< ;=I" return;F;>I"without property on tail;T;0;?[I" Jini;T;$@o;< ;=I" since;F;>I" 0.1.3;T;0;?0;$@;![;"I"nRemoves property. @param property [String] to remove @return [Jini] without property on tail @since 0.1.3;T;#0;$@;%F;&o;';(F;)iq;*it;+i;,@;@T;AI"Rdef remove_property(property) Jini.new(@head.gsub("#{property}()", '')) end;T;BI""def remove_property(property);T;6To;7;8F;9;;;;-I"Jini#add_attr;F;:[[I"key;T0[I" value;T0;[[@i~;T;: add_attr;;;[;{;IC; "=Additional attribute for xpath. @example'[@key="value"]';T;[o;< ;=I" param;F;>I"name of attr;T;I"key;T;?[I" String;T;$@o;< ;=I" param;F;>I"value of attr;T;I" value;T;?[I" String;T;$@o;< ;=I" return;F;>I"!with additional attr on tail;T;0;?[I" Jini;T;$@;![;"I"Additional attribute for xpath. @example'[@key="value"]' @param key [String] name of attr @param value [String] value of attr @return [Jini] with additional attr on tail;T;#0;$@;%F;&o;';(F;)iy;*i};+i;,@;@T;AI"Ndef add_attr(key, value) Jini.new("#{@head}[@#{key}=\"#{value}\"]") end;T;BI"def add_attr(key, value);T;6To;7;8F;9;;;;-I"Jini#add_attrs;F;:[[I"key;T0;[[@i;T;:add_attrs;;;[;{;IC; "Adds '@key' to tail.;T;[o;< ;=I" param;F;>I" the key;T;I"key;T;?[I" String;T;$@%o;< ;=I" return;F;>I""with additional value on tail;T;0;?[I" Jini;T;$@%;![;"I"cAdds '@key' to tail. @param key [String] the key @return [Jini] with additional value on tail;T;#0;$@%;%F;&o;';(F;)i};*i;+i;,@;@T;AI"9def add_attrs(key) Jini.new("#{@head}@#{key}") end;T;BI"def add_attrs(key);T;6To;7;8F;9;;;;-I"Jini#remove_attr;F;:[[I" name;T0;[[@i;T;:remove_attr;;;[;{;IC; "RRemoves attr by name. before: '/parent/child [@k="v"]' after: '/parent/child';T;[o;< ;=I" param;F;>I" of attr;T;I" name;T;?[I" String;T;$@@o;< ;=I" return;F;>I"without an attr;T;0;?[I" Jini;T;$@@;![;"I"Removes attr by name. before: '/parent/child [@k="v"]' after: '/parent/child' @param [String] name of attr @return [Jini] without an attr;T;#0;$@@;%F;&o;';(F;)i;*i;+i;,@;@T;AI"`def remove_attr(name) Jini.new( purge_head(/(\[@?#{name}="[^"]+"(\[\]+|\]))/) ) end;T;BI"def remove_attr(name);T;6To;7;8F;9;;;;-I"Jini#replace_attr_value;F;:[[I" name;T0[I" value;T0;[[@i;T;:replace_attr_value;;;[;{;IC; "bReplaces *all* attr *values* by name. Before: '[@id="some value"]' After: '[@id="new value"]';T;[o;< ;=I" param;F;>I" of attr;T;I" name;T;?[I" String;T;$@[o;< ;=I" param;F;>I"upd value;T;I" value;T;?[I" String;T;$@[o;< ;=I" return;F;>I"with replaced attr value;T;0;?[I" Jini;T;$@[;![;"I"Replaces *all* attr *values* by name. Before: '[@id="some value"]' After: '[@id="new value"]' @param name [String] of attr @param value [String] upd value @return [Jini] with replaced attr value;T;#0;$@[;%F;&o;';(F;)i;*i;+i;,@;@T;AI"def replace_attr_value(name, value) n_rxp = /(\[@?#{name}="[^"]+"(\[\]+|\]))/ attr = @head[n_rxp] attr[/"(.*?)"/] = "\"#{value}\"" Jini.new(@head.gsub(n_rxp, attr)) unless attr.nil? end;T;BI"(def replace_attr_value(name, value);T;6To;7;8F;9;;;;-I" Jini#all;F;:[;[[@i;T;:all;;;[;{;IC; ">Xpath with all elements. Addition an '*' to tail of xpath;T;[o;< ;=I" return;F;>I" object;T;0;?[I" Jini;T;$@~o;< ;=I" raise;F;>I""when method called after attr;T;0;?[I"InvalidPath;T;$@~;![;"I"Xpath with all elements. Addition an '*' to tail of xpath @return [Jini] object @raise [InvalidPath] when method called after attr;T;#0;$@~;%F;&o;';(F;)i;*i;+i;,@;@T;AI"{def all raise InvalidPath, 'You cannot add all tag after attr!' if @head[-1].eql?(']') Jini.new(add_node('*').to_s) end;T;BI" def all;T;6To;7;8F;9;;;;-I"Jini#add_nodes;F;:[[I" node;T0;[[@i;T;:add_nodes;;;[;{;IC; ">Xpath with all named elements. Addition '//node' to xpath;T;[o;< ;=I" param;F;>I" the node;T;I" node;T;?[I" String;T;$@o;< ;=I" return;F;>I"with additional nodes;T;0;?[I" Jini;T;$@;![;"I"|Xpath with all named elements. Addition '//node' to xpath @param node [String] the node @return [Jini] with additional nodes;T;#0;$@;%F;&o;';(F;)i;*i;+i;,@;@T;AI"I" number;T;I" position;T;?[I" Integer;T;$@o;< ;=I" return;F;>I"with selected index;T;0;?[I" Jini;T;$@o;< ;=I" raise;F;>I"%when method used after selection;T;0;?[I"InvalidPath;T;$@;![;"I"Access by index. Addition '[index]' to xpath @param position [Integer] number @return [Jini] with selected index @raise [InvalidPath] when method used after selection;T;#0;$@;%F;&o;';(F;)i;*i;+i;,@;@T;AI"def at(position) raise InvalidPath, 'Cant use at after selection' if @head.include? '::' Jini.new("#{@head}[#{position}]") end;T;BI"def at(position);T;6To;7;8F;9;;;;-I"Jini#selection;F;:[;[[@i;T;:selection;;;[;{;IC; "TReplace all '/' to '::'. If path doesn't contain invalid symbols for selection;T;[o;< ;=I" return;F;>I"with selection;T;0;?[I" Jini;T;$@o;< ;=I" raise;F;>I"(when path can't present with select;T;0;?[I"InvalidPath;T;$@;![;"I"Replace all '/' to '::'. If path doesn't contain invalid symbols for selection @return [Jini] with selection @raise [InvalidPath] when path can't present with select;T;#0;$@;%F;&o;';(F;)i;*i;+i;,@;@T;AI"def selection raise InvalidPath, 'Cannot select, path contains bad symbols' if bad_symbols? @head Jini.new(@head.gsub('/', '::').to_s) end;T;BI"def selection;T;6To;7;8F;9;;;;-I" Jini#or;F;:[[I" alpha;T0[I" beta;T0;[[@i;T;:or;;;[;{;IC; "#Adds '[alpha | beta]' in tail.;T;[o;< ;=I" param;F;>I"the alpha statement;T;I" alpha;T;?[I" String;T;$@o;< ;=I" param;F;>I"the beta statement;T;I" beta;T;?[I" String;T;$@o;< ;=I" return;F;>I"with condition on tail;T;0;?[I" Jini;T;$@;![;"I"Adds '[alpha | beta]' in tail. @param alpha [String] the alpha statement @param beta [String] the beta statement @return [Jini] with condition on tail;T;#0;$@;%F;&o;';(F;)i;*i;+i;,@;@T;AI"?def or(alpha, beta) action_between('|', alpha, beta) end;T;BI"def or(alpha, beta);T;6To;7;8F;9;;;;-I" Jini#lt;F;:[[I" alpha;T0[I" beta;T0;[[@i;T;:lt;;;[;{;IC; "1Less than. Addition '[alpha < beta]' to tail;T;[o;< ;=I" param;F;>I"the alpha statement;T;I" alpha;T;?[I" String;T;$@ o;< ;=I" param;F;>I"the beta statement;T;I" beta;T;?[I" Object;T;$@ o;< ;=I" return;F;>I"with condition on tail;T;0;?[I" Jini;T;$@ ;![;"I"Less than. Addition '[alpha < beta]' to tail @param alpha [String] the alpha statement @param beta [Object] the beta statement @return [Jini] with condition on tail;T;#0;$@ ;%F;&o;';(F;)i;*i;+i;,@;@T;AI"?def lt(alpha, beta) action_between('<', alpha, beta) end;T;BI"def lt(alpha, beta);T;6To;7;8F;9;;;;-I" Jini#gt;F;:[[I" alpha;T0[I" beta;T0;[[@i;T;:gt;;;[;{;IC; "4Greater than. Addition '[alpha > beta]' to tail;T;[o;< ;=I" param;F;>I"the alpha statement;T;I" alpha;T;?[I" String;T;$@/o;< ;=I" param;F;>I"the beta statement;T;I" beta;T;?[I" Object;T;$@/o;< ;=I" return;F;>I"with condition on tail;T;0;?[I" Jini;T;$@/;![;"I"Greater than. Addition '[alpha > beta]' to tail @param alpha [String] the alpha statement @param beta [Object] the beta statement @return [Jini] with condition on tail;T;#0;$@/;%F;&o;';(F;)i;*i;+i;,@;@T;AI"?def gt(alpha, beta) action_between('>', alpha, beta) end;T;BI"def gt(alpha, beta);T;6To;7;8F;9;;: private;-I"Jini#empty_check;F;:[[I" node;T0;[[@i;T;:empty_check;;;[;{;IC; ";T;[o;< ;=I" param;F;>I"node for check;T;I" node;T;?[I" String;T;$@Ro;< ;=I" raise;F;>I";T;0;?[I"InvalidPath;T;$@R;![;"I"(@param node [String] node for check;T;#0;$@R;%F;&o;';(F;)i;*i;+i;,@;@T;AI"ddef empty_check(node) raise InvalidPath, 'Invalid path, empty node' if node.length.eql? 0 end;T;BI"def empty_check(node);T;6To;7;8F;9;;;U;-I"Jini#space_check;F;:[[I" node;T0;[[@i;T;:space_check;;;[;{;IC; ";T;[o;< ;=I" param;F;>I"node for check;T;I" node;T;?[I" String;T;$@mo;< ;=I" raise;F;>@e;0;?[I"InvalidPath;T;$@m;![;"I"(@param node [String] node for check;T;#0;$@m;%F;&o;';(F;)i;*i;+i;,@;@T;AI"{def space_check(node) raise InvalidPath, "Nodes can't contain spaces: #{node} – contain space." if valid? node end;T;BI"def space_check(node);T;6To;7;8F;9;;;U;-I"Jini#bad_symbols?;F;:[[I" node;T0;[[@i;T;:bad_symbols?;;;[;{;IC; "&Regex: '[' or ']' or '@' or '//'.;T;[o;< ;=I" param;F;>I";T;I" node;T;?[I" String;T;$@o;< ;=I" return;F;>I"matching regex;T;0;?[I" Boolean;T;$@;![;"I"\Regex: '[' or ']' or '@' or '//'. @param node [String] @return [Boolean] matching regex;T;#0;$@;%F;&o;';(F;)i;*i;+i;,@;@T;AI"Mdef bad_symbols?(node) !!node.match(%r{[|]|@|//}) unless node.nil? end;T;BI"def bad_symbols?(node);T;6To;7;8F;9;;;U;-I"Jini#valid?;F;:[[I" node;T0;[[@i;T;: valid?;;;[;{;IC; "3Regex: '[' or ']' or '@' or '=' or '<' or '>'.;T;[o;< ;=I" param;F;>I"node for check;T;I" node;T;?[I" String;T;$@o;< ;=I" return;F;>I"matching regex;T;0;?[I" Boolean;T;$@;![;"I"xRegex: '[' or ']' or '@' or '=' or '<' or '>'. @param node [String] node for check @return [Boolean] matching regex;T;#0;$@;%F;&o;';(F;)i;*i;+i;,@;@T;AI"Ldef valid?(node) !node.match(/[|]|@|=|>|I"to be purged from the head;T;I" token;T;?[I"Regexp | String;T;$@;![;"I"WPurging head from token. @param [Regexp | String] token to be purged from the head;T;#0;$@;%F;&o;';(F;)i;*i;+i;,@;@T;AI"6def purge_head(token) @head.gsub(token, '') end;T;BI"def purge_head(token);T;6T; @; IC;[; @; IC;[; @; IC;{;IC;{;T;IC;{;T;T;{;[;[[@i,;T;: Jini;;;;;[;{;IC; "1The jini. Author:: Ivan Ivanchuk (clicker.heroes.acg@gmail.com) Copyright:: Copyright (c) 2022 Ivan Ivanchuck License:: MIT It's a simple XPATH builder. Class is thread safe. require 'jini' xpath = Jini.new('parent') .add_node('child') .add_attr('toy', 'plane') .to_s // parent/child[@toy="plane"];T;[;![;"I"2The jini. Author:: Ivan Ivanchuk (clicker.heroes.acg@gmail.com) Copyright:: Copyright (c) 2022 Ivan Ivanchuck License:: MIT It's a simple XPATH builder. Class is thread safe. require 'jini' xpath = Jini.new('parent') .add_node('child') .add_attr('toy', 'plane') .to_s // parent/child[@toy="plane"] ;T;#0;$@;%F;&o;';(F;)i;*i+;+i;,@;-I" Jini;F;.o;/ ;00;10;20;: Object;,@;40;5;; @; IC;[; @; IC;[; @; IC;{;IC;{;T;IC;{;T;T;{;[;[;F;;;;;;;[;{;IC; " ;T;[;![;"@e;#0;$@;+i;,0;-@e;\@:Jini::InvalidPath@ :Jini#initialize@:Jini#to_s@>:Jini#add_node@Y:Jini#remove_node@w:Jini#replace_node@:Jini#nodes@:Jini#add_property@:Jini#remove_property@:Jini#add_attr@:Jini#add_attrs@%:Jini#remove_attr@@:Jini#replace_attr_value@[: Jini#all@~:Jini#add_nodes@: Jini#at@:Jini#selection@: Jini#or@: Jini#lt@ : Jini#gt@/:Jini#empty_check@R:Jini#space_check@m:Jini#bad_symbols?@:Jini#valid?@:Jini#action_between@:Jini#purge_head@