Class: YAML::YRegexPath
Instance Attribute Summary collapse
-
#root ⇒ Object
readonly
Returns the value of attribute root.
-
#segments ⇒ Object
readonly
Returns the value of attribute segments.
-
#wanted_node_index ⇒ Object
readonly
Returns the value of attribute wanted_node_index.
Instance Method Summary collapse
-
#initialize(str) ⇒ YRegexPath
constructor
A new instance of YRegexPath.
Constructor Details
#initialize(str) ⇒ YRegexPath
Returns a new instance of YRegexPath.
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/yaml_extensions/yregexpath.rb', line 14 def initialize ( str ) raise ArgumentError, 'Argument must be a string' unless str.is_a?(String) @segments = [] @wanted_node_index = nil @root = (str[0] == ?/) while str =~ /^(\/|#)?((?:(?:\\.)|[^\\=\/#])+)(?:=((?:(?:\\.)|[^\\\/#])*))?/ if ($1 == "#") if (@wanted_node_index.nil?) @wanted_node_index = @segments.length else raise ArgumentError, 'More than a "#" given.' end end if ($3.nil?) @segments << Regexp.new($2) else @segments << [ Regexp.new($2), Regexp.new($3) ] end str = $' end @wanted_node_index = @segments.length if @wanted_node_index.nil? end |
Instance Attribute Details
#root ⇒ Object (readonly)
Returns the value of attribute root.
12 13 14 |
# File 'lib/yaml_extensions/yregexpath.rb', line 12 def root @root end |
#segments ⇒ Object (readonly)
Returns the value of attribute segments.
12 13 14 |
# File 'lib/yaml_extensions/yregexpath.rb', line 12 def segments @segments end |
#wanted_node_index ⇒ Object (readonly)
Returns the value of attribute wanted_node_index.
12 13 14 |
# File 'lib/yaml_extensions/yregexpath.rb', line 12 def wanted_node_index @wanted_node_index end |