formattedstring 0.0.1 → 0.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/Rakefile +1 -1
- data/doc/classes/Enumerable.html +10 -10
- data/doc/classes/Enumerable.src/M000026.html +6 -19
- data/doc/classes/Enumerable.src/M000027.html +34 -0
- data/doc/classes/FormattedString/Formats/Xml.html +16 -1
- data/doc/classes/FormattedString/Formats/Xml.src/M000004.html +3 -34
- data/doc/classes/FormattedString/Formats/Xml.src/M000005.html +49 -0
- data/doc/classes/Inflector/Inflections.html +40 -40
- data/doc/classes/Inflector/Inflections.src/M000020.html +4 -4
- data/doc/classes/Inflector/Inflections.src/M000021.html +4 -4
- data/doc/classes/Inflector/Inflections.src/M000022.html +4 -12
- data/doc/classes/Inflector/Inflections.src/M000023.html +12 -4
- data/doc/classes/Inflector/Inflections.src/M000024.html +4 -9
- data/doc/classes/Inflector/Inflections.src/M000025.html +23 -0
- data/doc/classes/Inflector.html +82 -82
- data/doc/classes/Inflector.src/M000006.html +6 -9
- data/doc/classes/Inflector.src/M000007.html +5 -5
- data/doc/classes/Inflector.src/M000008.html +9 -6
- data/doc/classes/Inflector.src/M000009.html +8 -4
- data/doc/classes/Inflector.src/M000010.html +4 -8
- data/doc/classes/Inflector.src/M000011.html +8 -4
- data/doc/classes/Inflector.src/M000012.html +4 -4
- data/doc/classes/Inflector.src/M000013.html +4 -4
- data/doc/classes/Inflector.src/M000014.html +4 -4
- data/doc/classes/Inflector.src/M000015.html +4 -5
- data/doc/classes/Inflector.src/M000016.html +5 -4
- data/doc/classes/Inflector.src/M000017.html +4 -8
- data/doc/classes/Inflector.src/M000018.html +7 -12
- data/doc/classes/Inflector.src/M000019.html +27 -0
- data/doc/created.rid +1 -1
- data/doc/files/lib/formatted_string/formats/xml_rb.html +1 -1
- data/doc/fr_method_index.html +24 -23
- data/lib/formatted_string/formats/xml.rb +4 -0
- metadata +6 -5
- data/doc/classes/Enumerable.src/M000025.html +0 -21
- data/doc/classes/Inflector/Inflections.src/M000019.html +0 -18
- data/doc/classes/Inflector.src/M000005.html +0 -22
data/Rakefile
CHANGED
data/doc/classes/Enumerable.html
CHANGED
@@ -80,8 +80,8 @@
|
|
80
80
|
<h3 class="section-bar">Methods</h3>
|
81
81
|
|
82
82
|
<div class="name-list">
|
83
|
-
<a href="#
|
84
|
-
<a href="#
|
83
|
+
<a href="#M000027">crawl</a>
|
84
|
+
<a href="#M000026">group_by</a>
|
85
85
|
</div>
|
86
86
|
</div>
|
87
87
|
|
@@ -103,12 +103,12 @@
|
|
103
103
|
<div id="methods">
|
104
104
|
<h3 class="section-bar">Public Instance methods</h3>
|
105
105
|
|
106
|
-
<div id="method-
|
107
|
-
<a name="
|
106
|
+
<div id="method-M000027" class="method-detail">
|
107
|
+
<a name="M000027"></a>
|
108
108
|
|
109
109
|
<div class="method-heading">
|
110
|
-
<a href="Enumerable.src/
|
111
|
-
onclick="popupCode('Enumerable.src/
|
110
|
+
<a href="Enumerable.src/M000027.html" target="Code" class="method-signature"
|
111
|
+
onclick="popupCode('Enumerable.src/M000027.html');return false;">
|
112
112
|
<span class="method-name">crawl</span><span class="method-args">() {|v| ...}</span>
|
113
113
|
</a>
|
114
114
|
</div>
|
@@ -117,12 +117,12 @@
|
|
117
117
|
</div>
|
118
118
|
</div>
|
119
119
|
|
120
|
-
<div id="method-
|
121
|
-
<a name="
|
120
|
+
<div id="method-M000026" class="method-detail">
|
121
|
+
<a name="M000026"></a>
|
122
122
|
|
123
123
|
<div class="method-heading">
|
124
|
-
<a href="Enumerable.src/
|
125
|
-
onclick="popupCode('Enumerable.src/
|
124
|
+
<a href="Enumerable.src/M000026.html" target="Code" class="method-signature"
|
125
|
+
onclick="popupCode('Enumerable.src/M000026.html');return false;">
|
126
126
|
<span class="method-name">group_by</span><span class="method-args">() {|element| ...}</span>
|
127
127
|
</a>
|
128
128
|
</div>
|
@@ -5,29 +5,16 @@
|
|
5
5
|
|
6
6
|
<html>
|
7
7
|
<head>
|
8
|
-
<title>
|
8
|
+
<title>group_by (Enumerable)</title>
|
9
9
|
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
|
10
10
|
<link rel="stylesheet" href="../.././rdoc-style.css" type="text/css" media="screen" />
|
11
11
|
</head>
|
12
12
|
<body class="standalone-code">
|
13
|
-
<pre><span class="ruby-comment cmt"># File lib/formatted_string/formats/xml.rb, line
|
14
|
-
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">
|
15
|
-
<span class="ruby-identifier">
|
16
|
-
|
17
|
-
<span class="ruby-identifier">
|
18
|
-
<span class="ruby-identifier">v</span> = <span class="ruby-keyword kw">case</span> <span class="ruby-identifier">block</span>.<span class="ruby-identifier">arity</span>
|
19
|
-
<span class="ruby-keyword kw">when</span> <span class="ruby-value">1</span>
|
20
|
-
<span class="ruby-keyword kw">yield</span>(<span class="ruby-identifier">v</span>)
|
21
|
-
<span class="ruby-keyword kw">when</span> <span class="ruby-value">2</span>
|
22
|
-
<span class="ruby-keyword kw">yield</span>(<span class="ruby-identifier">k</span>,<span class="ruby-identifier">v</span>)
|
23
|
-
<span class="ruby-keyword kw">when</span> <span class="ruby-value">3</span>
|
24
|
-
<span class="ruby-keyword kw">yield</span>(<span class="ruby-keyword kw">self</span>,<span class="ruby-identifier">k</span>,<span class="ruby-identifier">v</span>)
|
25
|
-
<span class="ruby-keyword kw">end</span>
|
26
|
-
<span class="ruby-keyword kw">if</span> <span class="ruby-identifier">v</span>.<span class="ruby-identifier">is_a?</span>(<span class="ruby-constant">Array</span>)
|
27
|
-
<span class="ruby-identifier">v</span>.<span class="ruby-identifier">crawl</span>(<span class="ruby-operator">&</span><span class="ruby-identifier">block</span>)
|
28
|
-
<span class="ruby-keyword kw">elsif</span> <span class="ruby-identifier">v</span>.<span class="ruby-identifier">is_a?</span>(<span class="ruby-constant">Hash</span>)
|
29
|
-
<span class="ruby-identifier">v</span>.<span class="ruby-identifier">crawl</span>(<span class="ruby-operator">&</span><span class="ruby-identifier">block</span>)
|
30
|
-
<span class="ruby-keyword kw">end</span>
|
13
|
+
<pre><span class="ruby-comment cmt"># File lib/formatted_string/formats/xml.rb, line 11</span>
|
14
|
+
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">group_by</span>
|
15
|
+
<span class="ruby-identifier">inject</span>({}) <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">groups</span>, <span class="ruby-identifier">element</span><span class="ruby-operator">|</span>
|
16
|
+
(<span class="ruby-identifier">groups</span>[<span class="ruby-keyword kw">yield</span>(<span class="ruby-identifier">element</span>)] <span class="ruby-operator">||=</span> []) <span class="ruby-operator"><<</span> <span class="ruby-identifier">element</span>
|
17
|
+
<span class="ruby-identifier">groups</span>
|
31
18
|
<span class="ruby-keyword kw">end</span>
|
32
19
|
<span class="ruby-keyword kw">end</span></pre>
|
33
20
|
</body>
|
@@ -0,0 +1,34 @@
|
|
1
|
+
<?xml version="1.0" encoding="iso-8859-1"?>
|
2
|
+
<!DOCTYPE html
|
3
|
+
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
4
|
+
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
5
|
+
|
6
|
+
<html>
|
7
|
+
<head>
|
8
|
+
<title>crawl (Enumerable)</title>
|
9
|
+
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
|
10
|
+
<link rel="stylesheet" href="../.././rdoc-style.css" type="text/css" media="screen" />
|
11
|
+
</head>
|
12
|
+
<body class="standalone-code">
|
13
|
+
<pre><span class="ruby-comment cmt"># File lib/formatted_string/formats/xml.rb, line 18</span>
|
14
|
+
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">crawl</span>(<span class="ruby-operator">&</span><span class="ruby-identifier">block</span>)
|
15
|
+
<span class="ruby-identifier">raise</span> <span class="ruby-constant">ArgumentError</span>, <span class="ruby-value str">"no block given"</span> <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">block_given?</span>
|
16
|
+
<span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">v</span><span class="ruby-operator">|</span>
|
17
|
+
<span class="ruby-identifier">k</span> = <span class="ruby-keyword kw">self</span>
|
18
|
+
<span class="ruby-identifier">v</span> = <span class="ruby-keyword kw">case</span> <span class="ruby-identifier">block</span>.<span class="ruby-identifier">arity</span>
|
19
|
+
<span class="ruby-keyword kw">when</span> <span class="ruby-value">1</span>
|
20
|
+
<span class="ruby-keyword kw">yield</span>(<span class="ruby-identifier">v</span>)
|
21
|
+
<span class="ruby-keyword kw">when</span> <span class="ruby-value">2</span>
|
22
|
+
<span class="ruby-keyword kw">yield</span>(<span class="ruby-identifier">k</span>,<span class="ruby-identifier">v</span>)
|
23
|
+
<span class="ruby-keyword kw">when</span> <span class="ruby-value">3</span>
|
24
|
+
<span class="ruby-keyword kw">yield</span>(<span class="ruby-keyword kw">self</span>,<span class="ruby-identifier">k</span>,<span class="ruby-identifier">v</span>)
|
25
|
+
<span class="ruby-keyword kw">end</span>
|
26
|
+
<span class="ruby-keyword kw">if</span> <span class="ruby-identifier">v</span>.<span class="ruby-identifier">is_a?</span>(<span class="ruby-constant">Array</span>)
|
27
|
+
<span class="ruby-identifier">v</span>.<span class="ruby-identifier">crawl</span>(<span class="ruby-operator">&</span><span class="ruby-identifier">block</span>)
|
28
|
+
<span class="ruby-keyword kw">elsif</span> <span class="ruby-identifier">v</span>.<span class="ruby-identifier">is_a?</span>(<span class="ruby-constant">Hash</span>)
|
29
|
+
<span class="ruby-identifier">v</span>.<span class="ruby-identifier">crawl</span>(<span class="ruby-operator">&</span><span class="ruby-identifier">block</span>)
|
30
|
+
<span class="ruby-keyword kw">end</span>
|
31
|
+
<span class="ruby-keyword kw">end</span>
|
32
|
+
<span class="ruby-keyword kw">end</span></pre>
|
33
|
+
</body>
|
34
|
+
</html>
|
@@ -80,7 +80,8 @@
|
|
80
80
|
<h3 class="section-bar">Methods</h3>
|
81
81
|
|
82
82
|
<div class="name-list">
|
83
|
-
<a href="#M000004"
|
83
|
+
<a href="#M000004">===</a>
|
84
|
+
<a href="#M000005">to_hash</a>
|
84
85
|
</div>
|
85
86
|
</div>
|
86
87
|
|
@@ -121,6 +122,20 @@
|
|
121
122
|
<div class="method-heading">
|
122
123
|
<a href="Xml.src/M000004.html" target="Code" class="method-signature"
|
123
124
|
onclick="popupCode('Xml.src/M000004.html');return false;">
|
125
|
+
<span class="method-name">===</span><span class="method-args">(other)</span>
|
126
|
+
</a>
|
127
|
+
</div>
|
128
|
+
|
129
|
+
<div class="method-description">
|
130
|
+
</div>
|
131
|
+
</div>
|
132
|
+
|
133
|
+
<div id="method-M000005" class="method-detail">
|
134
|
+
<a name="M000005"></a>
|
135
|
+
|
136
|
+
<div class="method-heading">
|
137
|
+
<a href="Xml.src/M000005.html" target="Code" class="method-signature"
|
138
|
+
onclick="popupCode('Xml.src/M000005.html');return false;">
|
124
139
|
<span class="method-name">to_hash</span><span class="method-args">(options={})</span>
|
125
140
|
</a>
|
126
141
|
</div>
|
@@ -5,45 +5,14 @@
|
|
5
5
|
|
6
6
|
<html>
|
7
7
|
<head>
|
8
|
-
<title
|
8
|
+
<title>=== (FormattedString::Formats::Xml)</title>
|
9
9
|
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
|
10
10
|
<link rel="stylesheet" href="../../../.././rdoc-style.css" type="text/css" media="screen" />
|
11
11
|
</head>
|
12
12
|
<body class="standalone-code">
|
13
13
|
<pre><span class="ruby-comment cmt"># File lib/formatted_string/formats/xml.rb, line 127</span>
|
14
|
-
<span class="ruby-keyword kw">def</span> <span class="ruby-
|
15
|
-
<span class="ruby-identifier">
|
16
|
-
|
17
|
-
<span class="ruby-identifier">stack</span> = []
|
18
|
-
<span class="ruby-identifier">parser</span> = <span class="ruby-constant">REXML</span><span class="ruby-operator">::</span><span class="ruby-constant">Parsers</span><span class="ruby-operator">::</span><span class="ruby-constant">BaseParser</span>.<span class="ruby-identifier">new</span>(<span class="ruby-keyword kw">self</span>)
|
19
|
-
|
20
|
-
<span class="ruby-keyword kw">while</span> <span class="ruby-keyword kw">true</span>
|
21
|
-
<span class="ruby-identifier">event</span> = <span class="ruby-identifier">parser</span>.<span class="ruby-identifier">pull</span>
|
22
|
-
<span class="ruby-keyword kw">case</span> <span class="ruby-identifier">event</span>[<span class="ruby-value">0</span>]
|
23
|
-
<span class="ruby-keyword kw">when</span> <span class="ruby-identifier">:end_document</span>
|
24
|
-
<span class="ruby-keyword kw">break</span>
|
25
|
-
<span class="ruby-keyword kw">when</span> <span class="ruby-identifier">:end_doctype</span>, <span class="ruby-identifier">:start_doctype</span>
|
26
|
-
<span class="ruby-comment cmt"># do nothing</span>
|
27
|
-
<span class="ruby-keyword kw">when</span> <span class="ruby-identifier">:start_element</span>
|
28
|
-
<span class="ruby-identifier">stack</span>.<span class="ruby-identifier">push</span> <span class="ruby-constant">REXMLUtilityNode</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">event</span>[<span class="ruby-value">1</span>], <span class="ruby-identifier">event</span>[<span class="ruby-value">2</span>])
|
29
|
-
<span class="ruby-keyword kw">when</span> <span class="ruby-identifier">:end_element</span>
|
30
|
-
<span class="ruby-keyword kw">if</span> <span class="ruby-identifier">stack</span>.<span class="ruby-identifier">size</span> <span class="ruby-operator">></span> <span class="ruby-value">1</span>
|
31
|
-
<span class="ruby-identifier">temp</span> = <span class="ruby-identifier">stack</span>.<span class="ruby-identifier">pop</span>
|
32
|
-
<span class="ruby-identifier">stack</span>.<span class="ruby-identifier">last</span>.<span class="ruby-identifier">add_node</span>(<span class="ruby-identifier">temp</span>)
|
33
|
-
<span class="ruby-keyword kw">end</span>
|
34
|
-
<span class="ruby-keyword kw">when</span> <span class="ruby-identifier">:text</span>, <span class="ruby-identifier">:cdata</span>
|
35
|
-
<span class="ruby-identifier">stack</span>.<span class="ruby-identifier">last</span>.<span class="ruby-identifier">add_node</span>(<span class="ruby-identifier">event</span>[<span class="ruby-value">1</span>]) <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">event</span>[<span class="ruby-value">1</span>].<span class="ruby-identifier">strip</span>.<span class="ruby-identifier">length</span> <span class="ruby-operator">==</span> <span class="ruby-value">0</span>
|
36
|
-
<span class="ruby-keyword kw">end</span>
|
37
|
-
<span class="ruby-keyword kw">end</span>
|
38
|
-
<span class="ruby-identifier">data</span> = <span class="ruby-identifier">stack</span>.<span class="ruby-identifier">pop</span>.<span class="ruby-identifier">to_hash</span>
|
39
|
-
|
40
|
-
<span class="ruby-comment cmt"># Turn any {} || {"nil" => "true"} into just nil</span>
|
41
|
-
<span class="ruby-keyword kw">if</span> <span class="ruby-identifier">options</span>[<span class="ruby-identifier">:report_nil</span>]
|
42
|
-
<span class="ruby-identifier">data</span>.<span class="ruby-identifier">crawl</span> {<span class="ruby-operator">|</span><span class="ruby-identifier">h</span>,<span class="ruby-identifier">k</span>,<span class="ruby-identifier">v</span><span class="ruby-operator">|</span> <span class="ruby-identifier">h</span>[<span class="ruby-identifier">k</span>] = <span class="ruby-keyword kw">nil</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">v</span> <span class="ruby-operator">==</span> {} <span class="ruby-operator">||</span> <span class="ruby-identifier">v</span> <span class="ruby-operator">==</span> {<span class="ruby-value str">'nil'</span> =<span class="ruby-operator">></span> <span class="ruby-value str">'true'</span>}; <span class="ruby-identifier">v</span>}
|
43
|
-
<span class="ruby-keyword kw">else</span>
|
44
|
-
<span class="ruby-identifier">data</span>.<span class="ruby-identifier">crawl</span> {<span class="ruby-operator">|</span><span class="ruby-identifier">h</span>,<span class="ruby-identifier">k</span>,<span class="ruby-identifier">v</span><span class="ruby-operator">|</span> <span class="ruby-identifier">h</span>[<span class="ruby-identifier">k</span>] = <span class="ruby-keyword kw">nil</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">v</span> <span class="ruby-operator">==</span> {}; <span class="ruby-identifier">v</span>}
|
45
|
-
<span class="ruby-keyword kw">end</span>
|
46
|
-
<span class="ruby-identifier">data</span>
|
14
|
+
<span class="ruby-keyword kw">def</span> <span class="ruby-operator">===</span>(<span class="ruby-identifier">other</span>)
|
15
|
+
<span class="ruby-identifier">to_hash</span> <span class="ruby-operator">==</span> <span class="ruby-identifier">other</span>.<span class="ruby-identifier">to_hash</span>
|
47
16
|
<span class="ruby-keyword kw">end</span></pre>
|
48
17
|
</body>
|
49
18
|
</html>
|
@@ -0,0 +1,49 @@
|
|
1
|
+
<?xml version="1.0" encoding="iso-8859-1"?>
|
2
|
+
<!DOCTYPE html
|
3
|
+
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
4
|
+
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
5
|
+
|
6
|
+
<html>
|
7
|
+
<head>
|
8
|
+
<title>to_hash (FormattedString::Formats::Xml)</title>
|
9
|
+
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
|
10
|
+
<link rel="stylesheet" href="../../../.././rdoc-style.css" type="text/css" media="screen" />
|
11
|
+
</head>
|
12
|
+
<body class="standalone-code">
|
13
|
+
<pre><span class="ruby-comment cmt"># File lib/formatted_string/formats/xml.rb, line 131</span>
|
14
|
+
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">to_hash</span>(<span class="ruby-identifier">options</span>={})
|
15
|
+
<span class="ruby-identifier">options</span> = <span class="ruby-constant">XML_OPTIONS</span>.<span class="ruby-identifier">merge</span>(<span class="ruby-identifier">options</span>)
|
16
|
+
|
17
|
+
<span class="ruby-identifier">stack</span> = []
|
18
|
+
<span class="ruby-identifier">parser</span> = <span class="ruby-constant">REXML</span><span class="ruby-operator">::</span><span class="ruby-constant">Parsers</span><span class="ruby-operator">::</span><span class="ruby-constant">BaseParser</span>.<span class="ruby-identifier">new</span>(<span class="ruby-keyword kw">self</span>)
|
19
|
+
|
20
|
+
<span class="ruby-keyword kw">while</span> <span class="ruby-keyword kw">true</span>
|
21
|
+
<span class="ruby-identifier">event</span> = <span class="ruby-identifier">parser</span>.<span class="ruby-identifier">pull</span>
|
22
|
+
<span class="ruby-keyword kw">case</span> <span class="ruby-identifier">event</span>[<span class="ruby-value">0</span>]
|
23
|
+
<span class="ruby-keyword kw">when</span> <span class="ruby-identifier">:end_document</span>
|
24
|
+
<span class="ruby-keyword kw">break</span>
|
25
|
+
<span class="ruby-keyword kw">when</span> <span class="ruby-identifier">:end_doctype</span>, <span class="ruby-identifier">:start_doctype</span>
|
26
|
+
<span class="ruby-comment cmt"># do nothing</span>
|
27
|
+
<span class="ruby-keyword kw">when</span> <span class="ruby-identifier">:start_element</span>
|
28
|
+
<span class="ruby-identifier">stack</span>.<span class="ruby-identifier">push</span> <span class="ruby-constant">REXMLUtilityNode</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">event</span>[<span class="ruby-value">1</span>], <span class="ruby-identifier">event</span>[<span class="ruby-value">2</span>])
|
29
|
+
<span class="ruby-keyword kw">when</span> <span class="ruby-identifier">:end_element</span>
|
30
|
+
<span class="ruby-keyword kw">if</span> <span class="ruby-identifier">stack</span>.<span class="ruby-identifier">size</span> <span class="ruby-operator">></span> <span class="ruby-value">1</span>
|
31
|
+
<span class="ruby-identifier">temp</span> = <span class="ruby-identifier">stack</span>.<span class="ruby-identifier">pop</span>
|
32
|
+
<span class="ruby-identifier">stack</span>.<span class="ruby-identifier">last</span>.<span class="ruby-identifier">add_node</span>(<span class="ruby-identifier">temp</span>)
|
33
|
+
<span class="ruby-keyword kw">end</span>
|
34
|
+
<span class="ruby-keyword kw">when</span> <span class="ruby-identifier">:text</span>, <span class="ruby-identifier">:cdata</span>
|
35
|
+
<span class="ruby-identifier">stack</span>.<span class="ruby-identifier">last</span>.<span class="ruby-identifier">add_node</span>(<span class="ruby-identifier">event</span>[<span class="ruby-value">1</span>]) <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">event</span>[<span class="ruby-value">1</span>].<span class="ruby-identifier">strip</span>.<span class="ruby-identifier">length</span> <span class="ruby-operator">==</span> <span class="ruby-value">0</span>
|
36
|
+
<span class="ruby-keyword kw">end</span>
|
37
|
+
<span class="ruby-keyword kw">end</span>
|
38
|
+
<span class="ruby-identifier">data</span> = <span class="ruby-identifier">stack</span>.<span class="ruby-identifier">pop</span>.<span class="ruby-identifier">to_hash</span>
|
39
|
+
|
40
|
+
<span class="ruby-comment cmt"># Turn any {} || {"nil" => "true"} into just nil</span>
|
41
|
+
<span class="ruby-keyword kw">if</span> <span class="ruby-identifier">options</span>[<span class="ruby-identifier">:report_nil</span>]
|
42
|
+
<span class="ruby-identifier">data</span>.<span class="ruby-identifier">crawl</span> {<span class="ruby-operator">|</span><span class="ruby-identifier">h</span>,<span class="ruby-identifier">k</span>,<span class="ruby-identifier">v</span><span class="ruby-operator">|</span> <span class="ruby-identifier">h</span>[<span class="ruby-identifier">k</span>] = <span class="ruby-keyword kw">nil</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">v</span> <span class="ruby-operator">==</span> {} <span class="ruby-operator">||</span> <span class="ruby-identifier">v</span> <span class="ruby-operator">==</span> {<span class="ruby-value str">'nil'</span> =<span class="ruby-operator">></span> <span class="ruby-value str">'true'</span>}; <span class="ruby-identifier">v</span>}
|
43
|
+
<span class="ruby-keyword kw">else</span>
|
44
|
+
<span class="ruby-identifier">data</span>.<span class="ruby-identifier">crawl</span> {<span class="ruby-operator">|</span><span class="ruby-identifier">h</span>,<span class="ruby-identifier">k</span>,<span class="ruby-identifier">v</span><span class="ruby-operator">|</span> <span class="ruby-identifier">h</span>[<span class="ruby-identifier">k</span>] = <span class="ruby-keyword kw">nil</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">v</span> <span class="ruby-operator">==</span> {}; <span class="ruby-identifier">v</span>}
|
45
|
+
<span class="ruby-keyword kw">end</span>
|
46
|
+
<span class="ruby-identifier">data</span>
|
47
|
+
<span class="ruby-keyword kw">end</span></pre>
|
48
|
+
</body>
|
49
|
+
</html>
|
@@ -81,7 +81,7 @@
|
|
81
81
|
<div id="description">
|
82
82
|
<p>
|
83
83
|
A singleton instance of this class is yielded by <a
|
84
|
-
href="../Inflector.html#
|
84
|
+
href="../Inflector.html#M000006">Inflector.inflections</a>, which can then
|
85
85
|
be used to specify additional inflection rules. Examples:
|
86
86
|
</p>
|
87
87
|
<pre>
|
@@ -96,7 +96,7 @@ be used to specify additional inflection rules. Examples:
|
|
96
96
|
</pre>
|
97
97
|
<p>
|
98
98
|
New rules are added at the top. So in the example above, the <a
|
99
|
-
href="Inflections.html#
|
99
|
+
href="Inflections.html#M000023">irregular</a> rule for octopus will now be
|
100
100
|
the first of the pluralization and singularization rules that is runs. This
|
101
101
|
guarantees that your rules run before any of the rules that may already
|
102
102
|
have been loaded.
|
@@ -111,12 +111,12 @@ have been loaded.
|
|
111
111
|
<h3 class="section-bar">Methods</h3>
|
112
112
|
|
113
113
|
<div class="name-list">
|
114
|
-
<a href="#
|
115
|
-
<a href="#
|
116
|
-
<a href="#
|
117
|
-
<a href="#
|
118
|
-
<a href="#
|
119
|
-
<a href="#
|
114
|
+
<a href="#M000025">clear</a>
|
115
|
+
<a href="#M000023">irregular</a>
|
116
|
+
<a href="#M000020">new</a>
|
117
|
+
<a href="#M000021">plural</a>
|
118
|
+
<a href="#M000022">singular</a>
|
119
|
+
<a href="#M000024">uncountable</a>
|
120
120
|
</div>
|
121
121
|
</div>
|
122
122
|
|
@@ -168,12 +168,12 @@ have been loaded.
|
|
168
168
|
<div id="methods">
|
169
169
|
<h3 class="section-bar">Public Class methods</h3>
|
170
170
|
|
171
|
-
<div id="method-
|
172
|
-
<a name="
|
171
|
+
<div id="method-M000020" class="method-detail">
|
172
|
+
<a name="M000020"></a>
|
173
173
|
|
174
174
|
<div class="method-heading">
|
175
|
-
<a href="Inflections.src/
|
176
|
-
onclick="popupCode('Inflections.src/
|
175
|
+
<a href="Inflections.src/M000020.html" target="Code" class="method-signature"
|
176
|
+
onclick="popupCode('Inflections.src/M000020.html');return false;">
|
177
177
|
<span class="method-name">new</span><span class="method-args">()</span>
|
178
178
|
</a>
|
179
179
|
</div>
|
@@ -184,12 +184,12 @@ have been loaded.
|
|
184
184
|
|
185
185
|
<h3 class="section-bar">Public Instance methods</h3>
|
186
186
|
|
187
|
-
<div id="method-
|
188
|
-
<a name="
|
187
|
+
<div id="method-M000025" class="method-detail">
|
188
|
+
<a name="M000025"></a>
|
189
189
|
|
190
190
|
<div class="method-heading">
|
191
|
-
<a href="Inflections.src/
|
192
|
-
onclick="popupCode('Inflections.src/
|
191
|
+
<a href="Inflections.src/M000025.html" target="Code" class="method-signature"
|
192
|
+
onclick="popupCode('Inflections.src/M000025.html');return false;">
|
193
193
|
<span class="method-name">clear</span><span class="method-args">(scope = :all)</span>
|
194
194
|
</a>
|
195
195
|
</div>
|
@@ -210,25 +210,25 @@ Examples:
|
|
210
210
|
</div>
|
211
211
|
</div>
|
212
212
|
|
213
|
-
<div id="method-
|
214
|
-
<a name="
|
213
|
+
<div id="method-M000023" class="method-detail">
|
214
|
+
<a name="M000023"></a>
|
215
215
|
|
216
216
|
<div class="method-heading">
|
217
|
-
<a href="Inflections.src/
|
218
|
-
onclick="popupCode('Inflections.src/
|
217
|
+
<a href="Inflections.src/M000023.html" target="Code" class="method-signature"
|
218
|
+
onclick="popupCode('Inflections.src/M000023.html');return false;">
|
219
219
|
<span class="method-name">irregular</span><span class="method-args">(singular, plural)</span>
|
220
220
|
</a>
|
221
221
|
</div>
|
222
222
|
|
223
223
|
<div class="method-description">
|
224
224
|
<p>
|
225
|
-
Specifies a <a href="Inflections.html#
|
226
|
-
href="Inflections.html#
|
225
|
+
Specifies a <a href="Inflections.html#M000020">new</a> <a
|
226
|
+
href="Inflections.html#M000023">irregular</a> that applies to both
|
227
227
|
pluralization and singularization at the same time. This can only be used
|
228
228
|
for strings, not regular expressions. You simply pass the <a
|
229
|
-
href="Inflections.html#
|
230
|
-
href="Inflections.html#
|
231
|
-
href="Inflections.html#
|
229
|
+
href="Inflections.html#M000023">irregular</a> in <a
|
230
|
+
href="Inflections.html#M000022">singular</a> and <a
|
231
|
+
href="Inflections.html#M000021">plural</a> form.
|
232
232
|
</p>
|
233
233
|
<p>
|
234
234
|
Examples:
|
@@ -240,19 +240,19 @@ Examples:
|
|
240
240
|
</div>
|
241
241
|
</div>
|
242
242
|
|
243
|
-
<div id="method-
|
244
|
-
<a name="
|
243
|
+
<div id="method-M000021" class="method-detail">
|
244
|
+
<a name="M000021"></a>
|
245
245
|
|
246
246
|
<div class="method-heading">
|
247
|
-
<a href="Inflections.src/
|
248
|
-
onclick="popupCode('Inflections.src/
|
247
|
+
<a href="Inflections.src/M000021.html" target="Code" class="method-signature"
|
248
|
+
onclick="popupCode('Inflections.src/M000021.html');return false;">
|
249
249
|
<span class="method-name">plural</span><span class="method-args">(rule, replacement)</span>
|
250
250
|
</a>
|
251
251
|
</div>
|
252
252
|
|
253
253
|
<div class="method-description">
|
254
254
|
<p>
|
255
|
-
Specifies a <a href="Inflections.html#
|
255
|
+
Specifies a <a href="Inflections.html#M000020">new</a> pluralization rule
|
256
256
|
and its replacement. The rule can either be a string or a regular
|
257
257
|
expression. The replacement should always be a string that may include
|
258
258
|
references to the matched data from the rule.
|
@@ -260,19 +260,19 @@ references to the matched data from the rule.
|
|
260
260
|
</div>
|
261
261
|
</div>
|
262
262
|
|
263
|
-
<div id="method-
|
264
|
-
<a name="
|
263
|
+
<div id="method-M000022" class="method-detail">
|
264
|
+
<a name="M000022"></a>
|
265
265
|
|
266
266
|
<div class="method-heading">
|
267
|
-
<a href="Inflections.src/
|
268
|
-
onclick="popupCode('Inflections.src/
|
267
|
+
<a href="Inflections.src/M000022.html" target="Code" class="method-signature"
|
268
|
+
onclick="popupCode('Inflections.src/M000022.html');return false;">
|
269
269
|
<span class="method-name">singular</span><span class="method-args">(rule, replacement)</span>
|
270
270
|
</a>
|
271
271
|
</div>
|
272
272
|
|
273
273
|
<div class="method-description">
|
274
274
|
<p>
|
275
|
-
Specifies a <a href="Inflections.html#
|
275
|
+
Specifies a <a href="Inflections.html#M000020">new</a> singularization rule
|
276
276
|
and its replacement. The rule can either be a string or a regular
|
277
277
|
expression. The replacement should always be a string that may include
|
278
278
|
references to the matched data from the rule.
|
@@ -280,19 +280,19 @@ references to the matched data from the rule.
|
|
280
280
|
</div>
|
281
281
|
</div>
|
282
282
|
|
283
|
-
<div id="method-
|
284
|
-
<a name="
|
283
|
+
<div id="method-M000024" class="method-detail">
|
284
|
+
<a name="M000024"></a>
|
285
285
|
|
286
286
|
<div class="method-heading">
|
287
|
-
<a href="Inflections.src/
|
288
|
-
onclick="popupCode('Inflections.src/
|
287
|
+
<a href="Inflections.src/M000024.html" target="Code" class="method-signature"
|
288
|
+
onclick="popupCode('Inflections.src/M000024.html');return false;">
|
289
289
|
<span class="method-name">uncountable</span><span class="method-args">(*words)</span>
|
290
290
|
</a>
|
291
291
|
</div>
|
292
292
|
|
293
293
|
<div class="method-description">
|
294
294
|
<p>
|
295
|
-
Add <a href="Inflections.html#
|
295
|
+
Add <a href="Inflections.html#M000024">uncountable</a> words that
|
296
296
|
shouldn‘t be attempted inflected.
|
297
297
|
</p>
|
298
298
|
<p>
|
@@ -5,14 +5,14 @@
|
|
5
5
|
|
6
6
|
<html>
|
7
7
|
<head>
|
8
|
-
<title>
|
8
|
+
<title>new (Inflector::Inflections)</title>
|
9
9
|
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
|
10
10
|
<link rel="stylesheet" href="../../.././rdoc-style.css" type="text/css" media="screen" />
|
11
11
|
</head>
|
12
12
|
<body class="standalone-code">
|
13
|
-
<pre><span class="ruby-comment cmt"># File lib/inflector.rb, line
|
14
|
-
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">
|
15
|
-
<span class="ruby-ivar">@plurals</span
|
13
|
+
<pre><span class="ruby-comment cmt"># File lib/inflector.rb, line 27</span>
|
14
|
+
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">initialize</span>
|
15
|
+
<span class="ruby-ivar">@plurals</span>, <span class="ruby-ivar">@singulars</span>, <span class="ruby-ivar">@uncountables</span> = [], [], []
|
16
16
|
<span class="ruby-keyword kw">end</span></pre>
|
17
17
|
</body>
|
18
18
|
</html>
|