pincerna 1.1.3
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.
- checksums.yaml +7 -0
- data/.gitignore +7 -0
- data/.rubocop.yml +77 -0
- data/.travis-gemfile +17 -0
- data/.travis.yml +7 -0
- data/.yardopts +1 -0
- data/CHANGELOG.md +3 -0
- data/Gemfile +23 -0
- data/LICENSE.md +21 -0
- data/README.md +211 -0
- data/Rakefile +45 -0
- data/bin/pincernad +56 -0
- data/docs/Pincerna.html +130 -0
- data/docs/Pincerna/Base.html +3051 -0
- data/docs/Pincerna/Bookmark.html +523 -0
- data/docs/Pincerna/Cache.html +767 -0
- data/docs/Pincerna/ChromeBookmark.html +308 -0
- data/docs/Pincerna/CurrencyConversion.html +589 -0
- data/docs/Pincerna/FirefoxBookmark.html +328 -0
- data/docs/Pincerna/Ip.html +1017 -0
- data/docs/Pincerna/Map.html +399 -0
- data/docs/Pincerna/SafariBookmark.html +308 -0
- data/docs/Pincerna/Server.html +673 -0
- data/docs/Pincerna/Translation.html +517 -0
- data/docs/Pincerna/UnitConversion.html +1042 -0
- data/docs/Pincerna/Version.html +189 -0
- data/docs/Pincerna/Vpn.html +561 -0
- data/docs/Pincerna/Weather.html +837 -0
- data/docs/_index.html +298 -0
- data/docs/class_list.html +54 -0
- data/docs/css/common.css +1 -0
- data/docs/css/full_list.css +57 -0
- data/docs/css/style.css +338 -0
- data/docs/file.README.html +327 -0
- data/docs/file_list.html +56 -0
- data/docs/frames.html +28 -0
- data/docs/index.html +327 -0
- data/docs/js/app.js +214 -0
- data/docs/js/full_list.js +178 -0
- data/docs/js/jquery.js +4 -0
- data/docs/method_list.html +389 -0
- data/docs/top-level-namespace.html +112 -0
- data/icon.png +0 -0
- data/images/chrome.png +0 -0
- data/images/currency.png +0 -0
- data/images/firefox.png +0 -0
- data/images/map.png +0 -0
- data/images/network.png +0 -0
- data/images/safari.png +0 -0
- data/images/translate.png +0 -0
- data/images/unit.png +0 -0
- data/images/vpn.png +0 -0
- data/images/weather.png +0 -0
- data/info.plist +961 -0
- data/it.cowtech.pincernad.plist +19 -0
- data/lib/pincerna.rb +30 -0
- data/lib/pincerna/base.rb +258 -0
- data/lib/pincerna/bookmark.rb +80 -0
- data/lib/pincerna/cache.rb +61 -0
- data/lib/pincerna/chrome_bookmark.rb +40 -0
- data/lib/pincerna/currency_conversion.rb +134 -0
- data/lib/pincerna/firefox_bookmark.rb +92 -0
- data/lib/pincerna/ip.rb +135 -0
- data/lib/pincerna/map.rb +30 -0
- data/lib/pincerna/safari_bookmark.rb +40 -0
- data/lib/pincerna/server.rb +85 -0
- data/lib/pincerna/translation.rb +67 -0
- data/lib/pincerna/unit_conversion.rb +120 -0
- data/lib/pincerna/version.rb +24 -0
- data/lib/pincerna/vpn.rb +74 -0
- data/lib/pincerna/weather.rb +188 -0
- data/pincerna.alfredworkflow +0 -0
- data/pincerna.gemspec +36 -0
- data/pincerna.sh +9 -0
- data/spec/cassettes/Pincerna_CurrencyConversion/_perform_filtering/should_return_valid_values.yml +38 -0
- data/spec/cassettes/Pincerna_Ip/_get_local_addresses/should_return_a_list_of_addresses.yml +47 -0
- data/spec/cassettes/Pincerna_Ip/_get_public_address/should_return_public_IP_address.yml +44 -0
- data/spec/cassettes/Pincerna_Translation/_perform_filtering/should_default_from_English_to_the_given_language_when_only_one_is_present.yml +124 -0
- data/spec/cassettes/Pincerna_Translation/_perform_filtering/should_query_Google_Translate_for_sentences_returning_no_alternatives.yml +51 -0
- data/spec/cassettes/Pincerna_Translation/_perform_filtering/should_query_Google_Translate_for_single_words.yml +71 -0
- data/spec/cassettes/Pincerna_Weather/_get_forecast/should_append_name.yml +177 -0
- data/spec/cassettes/Pincerna_Weather/_get_forecast/should_get_correct_forecasts.yml +339 -0
- data/spec/cassettes/Pincerna_Weather/_lookup_places/should_return_an_existing_WOEID_without_making_any_request.yml +56 -0
- data/spec/cassettes/Pincerna_Weather/_lookup_places/should_search_for_places.yml +189 -0
- data/spec/cassettes/Pincerna_Weather/_perform_filtering/should_get_forecast.yml +56 -0
- data/spec/coverage_helper.rb +44 -0
- data/spec/pincerna/base_spec.rb +166 -0
- data/spec/pincerna/bookmark_spec.rb +65 -0
- data/spec/pincerna/cache_spec.rb +88 -0
- data/spec/pincerna/chrome_bookmark_spec.rb +114 -0
- data/spec/pincerna/currency_conversion_spec.rb +46 -0
- data/spec/pincerna/firefox_bookmark_spec.rb +46 -0
- data/spec/pincerna/ip_spec.rb +194 -0
- data/spec/pincerna/map_spec.rb +24 -0
- data/spec/pincerna/safari_bookmark_spec.rb +237 -0
- data/spec/pincerna/server_spec.rb +108 -0
- data/spec/pincerna/translation_spec.rb +55 -0
- data/spec/pincerna/unit_conversion_spec.rb +98 -0
- data/spec/pincerna/vpn_spec.rb +68 -0
- data/spec/pincerna/weather_spec.rb +131 -0
- data/spec/spec_helper.rb +48 -0
- metadata +283 -0
|
@@ -0,0 +1,517 @@
|
|
|
1
|
+
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
|
2
|
+
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
|
3
|
+
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
|
4
|
+
<head>
|
|
5
|
+
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
|
6
|
+
<title>
|
|
7
|
+
Class: Pincerna::Translation
|
|
8
|
+
|
|
9
|
+
— Documentation by YARD 0.8.7
|
|
10
|
+
|
|
11
|
+
</title>
|
|
12
|
+
|
|
13
|
+
<link rel="stylesheet" href="../css/style.css" type="text/css" charset="utf-8" />
|
|
14
|
+
|
|
15
|
+
<link rel="stylesheet" href="../css/common.css" type="text/css" charset="utf-8" />
|
|
16
|
+
|
|
17
|
+
<script type="text/javascript" charset="utf-8">
|
|
18
|
+
hasFrames = window.top.frames.main ? true : false;
|
|
19
|
+
relpath = '../';
|
|
20
|
+
framesUrl = "../frames.html#!" + escape(window.location.href);
|
|
21
|
+
</script>
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
<script type="text/javascript" charset="utf-8" src="../js/jquery.js"></script>
|
|
25
|
+
|
|
26
|
+
<script type="text/javascript" charset="utf-8" src="../js/app.js"></script>
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
</head>
|
|
30
|
+
<body>
|
|
31
|
+
<div id="header">
|
|
32
|
+
<div id="menu">
|
|
33
|
+
|
|
34
|
+
<a href="../_index.html">Index (T)</a> »
|
|
35
|
+
<span class='title'><span class='object_link'><a href="../Pincerna.html" title="Pincerna (module)">Pincerna</a></span></span>
|
|
36
|
+
»
|
|
37
|
+
<span class="title">Translation</span>
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
<div class="noframes"><span class="title">(</span><a href="." target="_top">no frames</a><span class="title">)</span></div>
|
|
41
|
+
</div>
|
|
42
|
+
|
|
43
|
+
<div id="search">
|
|
44
|
+
|
|
45
|
+
<a class="full_list_link" id="class_list_link"
|
|
46
|
+
href="../class_list.html">
|
|
47
|
+
Class List
|
|
48
|
+
</a>
|
|
49
|
+
|
|
50
|
+
<a class="full_list_link" id="method_list_link"
|
|
51
|
+
href="../method_list.html">
|
|
52
|
+
Method List
|
|
53
|
+
</a>
|
|
54
|
+
|
|
55
|
+
<a class="full_list_link" id="file_list_link"
|
|
56
|
+
href="../file_list.html">
|
|
57
|
+
File List
|
|
58
|
+
</a>
|
|
59
|
+
|
|
60
|
+
</div>
|
|
61
|
+
<div class="clear"></div>
|
|
62
|
+
</div>
|
|
63
|
+
|
|
64
|
+
<iframe id="search_frame"></iframe>
|
|
65
|
+
|
|
66
|
+
<div id="content"><h1>Class: Pincerna::Translation
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
|
|
70
|
+
</h1>
|
|
71
|
+
|
|
72
|
+
<dl class="box">
|
|
73
|
+
|
|
74
|
+
<dt class="r1">Inherits:</dt>
|
|
75
|
+
<dd class="r1">
|
|
76
|
+
<span class="inheritName"><span class='object_link'><a href="Base.html" title="Pincerna::Base (class)">Base</a></span></span>
|
|
77
|
+
|
|
78
|
+
<ul class="fullTree">
|
|
79
|
+
<li>Object</li>
|
|
80
|
+
|
|
81
|
+
<li class="next"><span class='object_link'><a href="Base.html" title="Pincerna::Base (class)">Base</a></span></li>
|
|
82
|
+
|
|
83
|
+
<li class="next">Pincerna::Translation</li>
|
|
84
|
+
|
|
85
|
+
</ul>
|
|
86
|
+
<a href="#" class="inheritanceTree">show all</a>
|
|
87
|
+
|
|
88
|
+
</dd>
|
|
89
|
+
|
|
90
|
+
|
|
91
|
+
|
|
92
|
+
|
|
93
|
+
|
|
94
|
+
|
|
95
|
+
|
|
96
|
+
|
|
97
|
+
|
|
98
|
+
<dt class="r2 last">Defined in:</dt>
|
|
99
|
+
<dd class="r2 last">lib/pincerna/translation.rb</dd>
|
|
100
|
+
|
|
101
|
+
</dl>
|
|
102
|
+
<div class="clear"></div>
|
|
103
|
+
|
|
104
|
+
<h2>Overview</h2><div class="docstring">
|
|
105
|
+
<div class="discussion">
|
|
106
|
+
<p>Translates text using Google Translate.</p>
|
|
107
|
+
|
|
108
|
+
|
|
109
|
+
</div>
|
|
110
|
+
</div>
|
|
111
|
+
<div class="tags">
|
|
112
|
+
|
|
113
|
+
|
|
114
|
+
</div>
|
|
115
|
+
<h2>Constant Summary</h2>
|
|
116
|
+
|
|
117
|
+
<dl class="constants">
|
|
118
|
+
|
|
119
|
+
<dt id="MATCHER-constant" class="">MATCHER =
|
|
120
|
+
<div class="docstring">
|
|
121
|
+
<div class="discussion">
|
|
122
|
+
<p>The expression to match.</p>
|
|
123
|
+
|
|
124
|
+
|
|
125
|
+
</div>
|
|
126
|
+
</div>
|
|
127
|
+
<div class="tags">
|
|
128
|
+
|
|
129
|
+
|
|
130
|
+
</div>
|
|
131
|
+
</dt>
|
|
132
|
+
<dd><pre class="code"><span class='tstring'><span class='regexp_beg'>/</span><span class='tstring_content'>^
|
|
133
|
+
(from\s+)?(?<from>[a-z_-]{2,5})
|
|
134
|
+
\s+
|
|
135
|
+
(to\s+)?((?<to>[a-z_-]{2,5})\s+)?
|
|
136
|
+
(?<text>.+)
|
|
137
|
+
$</span><span class='regexp_end'>/mix</span></span></pre></dd>
|
|
138
|
+
|
|
139
|
+
<dt id="RELEVANT_MATCHES-constant" class="">RELEVANT_MATCHES =
|
|
140
|
+
<div class="docstring">
|
|
141
|
+
<div class="discussion">
|
|
142
|
+
<p>Relevant groups in the match.</p>
|
|
143
|
+
|
|
144
|
+
|
|
145
|
+
</div>
|
|
146
|
+
</div>
|
|
147
|
+
<div class="tags">
|
|
148
|
+
|
|
149
|
+
|
|
150
|
+
</div>
|
|
151
|
+
</dt>
|
|
152
|
+
<dd><pre class="code"><span class='lbrace'>{</span>
|
|
153
|
+
<span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>from</span><span class='tstring_end'>"</span></span> <span class='op'>=></span> <span class='tlambda'>-></span><span class='lparen'>(</span><span class='id identifier rubyid__'>_</span><span class='comma'>,</span> <span class='id identifier rubyid_value'>value</span><span class='rparen'>)</span> <span class='tlambeg'>{</span> <span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_downcase'>downcase</span> <span class='rbrace'>}</span><span class='comma'>,</span>
|
|
154
|
+
<span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>to</span><span class='tstring_end'>"</span></span> <span class='op'>=></span> <span class='tlambda'>-></span><span class='lparen'>(</span><span class='id identifier rubyid__'>_</span><span class='comma'>,</span> <span class='id identifier rubyid_value'>value</span><span class='rparen'>)</span> <span class='tlambeg'>{</span> <span class='id identifier rubyid_value'>value</span> <span class='op'>&&</span> <span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_downcase'>downcase</span> <span class='rbrace'>}</span><span class='comma'>,</span>
|
|
155
|
+
<span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>text</span><span class='tstring_end'>"</span></span> <span class='op'>=></span> <span class='tlambda'>-></span><span class='lparen'>(</span><span class='id identifier rubyid__'>_</span><span class='comma'>,</span> <span class='id identifier rubyid_value'>value</span><span class='rparen'>)</span> <span class='tlambeg'>{</span> <span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_strip'>strip</span> <span class='rbrace'>}</span><span class='comma'>,</span>
|
|
156
|
+
<span class='rbrace'>}</span></pre></dd>
|
|
157
|
+
|
|
158
|
+
<dt id="ICON-constant" class="">ICON =
|
|
159
|
+
<div class="docstring">
|
|
160
|
+
<div class="discussion">
|
|
161
|
+
<p>The icon to show for each feedback item.</p>
|
|
162
|
+
|
|
163
|
+
|
|
164
|
+
</div>
|
|
165
|
+
</div>
|
|
166
|
+
<div class="tags">
|
|
167
|
+
|
|
168
|
+
|
|
169
|
+
</div>
|
|
170
|
+
</dt>
|
|
171
|
+
<dd><pre class="code"><span class='const'>Pincerna</span><span class='op'>::</span><span class='const'>Base</span><span class='op'>::</span><span class='const'>ROOT</span> <span class='op'>+</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>/images/translate.png</span><span class='tstring_end'>"</span></span></pre></dd>
|
|
172
|
+
|
|
173
|
+
<dt id="URL-constant" class="">URL =
|
|
174
|
+
<div class="docstring">
|
|
175
|
+
<div class="discussion">
|
|
176
|
+
<p>The URL of the webservice.</p>
|
|
177
|
+
|
|
178
|
+
|
|
179
|
+
</div>
|
|
180
|
+
</div>
|
|
181
|
+
<div class="tags">
|
|
182
|
+
|
|
183
|
+
|
|
184
|
+
</div>
|
|
185
|
+
</dt>
|
|
186
|
+
<dd><pre class="code"><span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>http://translate.google.com.br/translate_a/t</span><span class='tstring_end'>"</span></span></pre></dd>
|
|
187
|
+
|
|
188
|
+
</dl>
|
|
189
|
+
|
|
190
|
+
|
|
191
|
+
|
|
192
|
+
|
|
193
|
+
|
|
194
|
+
|
|
195
|
+
<h3 class="inherited">Constants inherited
|
|
196
|
+
from <span class='object_link'><a href="Base.html" title="Pincerna::Base (class)">Base</a></span></h3>
|
|
197
|
+
<p class="inherited"><span class='object_link'><a href="Base.html#CACHE_ROOT-constant" title="Pincerna::Base::CACHE_ROOT (constant)">Base::CACHE_ROOT</a></span>, <span class='object_link'><a href="Base.html#FULL_NAME-constant" title="Pincerna::Base::FULL_NAME (constant)">Base::FULL_NAME</a></span>, <span class='object_link'><a href="Base.html#ROOT-constant" title="Pincerna::Base::ROOT (constant)">Base::ROOT</a></span>, <span class='object_link'><a href="Base.html#TYPES-constant" title="Pincerna::Base::TYPES (constant)">Base::TYPES</a></span>, <span class='object_link'><a href="Base.html#WORKFLOW_ROOT-constant" title="Pincerna::Base::WORKFLOW_ROOT (constant)">Base::WORKFLOW_ROOT</a></span></p>
|
|
198
|
+
|
|
199
|
+
|
|
200
|
+
|
|
201
|
+
|
|
202
|
+
<h2>Instance Attribute Summary</h2>
|
|
203
|
+
|
|
204
|
+
<h3 class="inherited">Attributes inherited from <span class='object_link'><a href="Base.html" title="Pincerna::Base (class)">Base</a></span></h3>
|
|
205
|
+
<p class="inherited"><span class='object_link'><a href="Base.html#format-instance_method" title="Pincerna::Base#format (method)">#format</a></span>, <span class='object_link'><a href="Base.html#format_content_type-instance_method" title="Pincerna::Base#format_content_type (method)">#format_content_type</a></span>, <span class='object_link'><a href="Base.html#output-instance_method" title="Pincerna::Base#output (method)">#output</a></span></p>
|
|
206
|
+
|
|
207
|
+
|
|
208
|
+
|
|
209
|
+
<h2>
|
|
210
|
+
Instance Method Summary
|
|
211
|
+
<small>(<a href="#" class="summary_toggle">collapse</a>)</small>
|
|
212
|
+
</h2>
|
|
213
|
+
|
|
214
|
+
<ul class="summary">
|
|
215
|
+
|
|
216
|
+
<li class="public ">
|
|
217
|
+
<span class="summary_signature">
|
|
218
|
+
|
|
219
|
+
<a href="#perform_filtering-instance_method" title="#perform_filtering (instance method)">- (Hash|NilClass) <strong>perform_filtering</strong>(from, to, value) </a>
|
|
220
|
+
|
|
221
|
+
|
|
222
|
+
|
|
223
|
+
</span>
|
|
224
|
+
|
|
225
|
+
|
|
226
|
+
|
|
227
|
+
|
|
228
|
+
|
|
229
|
+
|
|
230
|
+
|
|
231
|
+
|
|
232
|
+
|
|
233
|
+
<span class="summary_desc"><div class='inline'><p>Translates text using Google Translate.</p>
|
|
234
|
+
</div></span>
|
|
235
|
+
|
|
236
|
+
</li>
|
|
237
|
+
|
|
238
|
+
|
|
239
|
+
<li class="public ">
|
|
240
|
+
<span class="summary_signature">
|
|
241
|
+
|
|
242
|
+
<a href="#process_results-instance_method" title="#process_results (instance method)">- (Array) <strong>process_results</strong>(results) </a>
|
|
243
|
+
|
|
244
|
+
|
|
245
|
+
|
|
246
|
+
</span>
|
|
247
|
+
|
|
248
|
+
|
|
249
|
+
|
|
250
|
+
|
|
251
|
+
|
|
252
|
+
|
|
253
|
+
|
|
254
|
+
|
|
255
|
+
|
|
256
|
+
<span class="summary_desc"><div class='inline'><p>Processes items to obtain feedback items.</p>
|
|
257
|
+
</div></span>
|
|
258
|
+
|
|
259
|
+
</li>
|
|
260
|
+
|
|
261
|
+
|
|
262
|
+
</ul>
|
|
263
|
+
|
|
264
|
+
|
|
265
|
+
|
|
266
|
+
|
|
267
|
+
|
|
268
|
+
|
|
269
|
+
|
|
270
|
+
|
|
271
|
+
|
|
272
|
+
|
|
273
|
+
|
|
274
|
+
<h3 class="inherited">Methods inherited from <span class='object_link'><a href="Base.html" title="Pincerna::Base (class)">Base</a></span></h3>
|
|
275
|
+
<p class="inherited"><span class='object_link'><a href="Base.html#add_feedback_item-instance_method" title="Pincerna::Base#add_feedback_item (method)">#add_feedback_item</a></span>, <span class='object_link'><a href="Base.html#execute%21-class_method" title="Pincerna::Base.execute! (method)">execute!</a></span>, <span class='object_link'><a href="Base.html#filter-instance_method" title="Pincerna::Base#filter (method)">#filter</a></span>, <span class='object_link'><a href="Base.html#format_float-instance_method" title="Pincerna::Base#format_float (method)">#format_float</a></span>, <span class='object_link'><a href="Base.html#initialize-instance_method" title="Pincerna::Base#initialize (method)">#initialize</a></span>, <span class='object_link'><a href="Base.html#output_feedback-instance_method" title="Pincerna::Base#output_feedback (method)">#output_feedback</a></span>, <span class='object_link'><a href="Base.html#round_float-instance_method" title="Pincerna::Base#round_float (method)">#round_float</a></span></p>
|
|
276
|
+
<div id="constructor_details" class="method_details_list">
|
|
277
|
+
<h2>Constructor Details</h2>
|
|
278
|
+
|
|
279
|
+
<p class="notice">This class inherits a constructor from <span class='object_link'><a href="Base.html#initialize-instance_method" title="Pincerna::Base#initialize (method)">Pincerna::Base</a></span></p>
|
|
280
|
+
|
|
281
|
+
</div>
|
|
282
|
+
|
|
283
|
+
|
|
284
|
+
<div id="instance_method_details" class="method_details_list">
|
|
285
|
+
<h2>Instance Method Details</h2>
|
|
286
|
+
|
|
287
|
+
|
|
288
|
+
<div class="method_details first">
|
|
289
|
+
<h3 class="signature first" id="perform_filtering-instance_method">
|
|
290
|
+
|
|
291
|
+
- (<tt>Hash|NilClass</tt>) <strong>perform_filtering</strong>(from, to, value)
|
|
292
|
+
|
|
293
|
+
|
|
294
|
+
|
|
295
|
+
|
|
296
|
+
|
|
297
|
+
</h3><div class="docstring">
|
|
298
|
+
<div class="discussion">
|
|
299
|
+
<p>Translates text using Google Translate.</p>
|
|
300
|
+
|
|
301
|
+
|
|
302
|
+
</div>
|
|
303
|
+
</div>
|
|
304
|
+
<div class="tags">
|
|
305
|
+
<p class="tag_title">Parameters:</p>
|
|
306
|
+
<ul class="param">
|
|
307
|
+
|
|
308
|
+
<li>
|
|
309
|
+
|
|
310
|
+
<span class='name'>from</span>
|
|
311
|
+
|
|
312
|
+
|
|
313
|
+
<span class='type'>(<tt>String</tt>)</span>
|
|
314
|
+
|
|
315
|
+
|
|
316
|
+
|
|
317
|
+
—
|
|
318
|
+
<div class='inline'><p>The code of the source language.</p>
|
|
319
|
+
</div>
|
|
320
|
+
|
|
321
|
+
</li>
|
|
322
|
+
|
|
323
|
+
<li>
|
|
324
|
+
|
|
325
|
+
<span class='name'>to</span>
|
|
326
|
+
|
|
327
|
+
|
|
328
|
+
<span class='type'>(<tt>String</tt>)</span>
|
|
329
|
+
|
|
330
|
+
|
|
331
|
+
|
|
332
|
+
—
|
|
333
|
+
<div class='inline'><p>The code of the target language.</p>
|
|
334
|
+
</div>
|
|
335
|
+
|
|
336
|
+
</li>
|
|
337
|
+
|
|
338
|
+
<li>
|
|
339
|
+
|
|
340
|
+
<span class='name'>value</span>
|
|
341
|
+
|
|
342
|
+
|
|
343
|
+
<span class='type'>(<tt>String</tt>)</span>
|
|
344
|
+
|
|
345
|
+
|
|
346
|
+
|
|
347
|
+
—
|
|
348
|
+
<div class='inline'><p>The text to translate.</p>
|
|
349
|
+
</div>
|
|
350
|
+
|
|
351
|
+
</li>
|
|
352
|
+
|
|
353
|
+
</ul>
|
|
354
|
+
|
|
355
|
+
<p class="tag_title">Returns:</p>
|
|
356
|
+
<ul class="return">
|
|
357
|
+
|
|
358
|
+
<li>
|
|
359
|
+
|
|
360
|
+
|
|
361
|
+
<span class='type'>(<tt>Hash|NilClass</tt>)</span>
|
|
362
|
+
|
|
363
|
+
|
|
364
|
+
|
|
365
|
+
—
|
|
366
|
+
<div class='inline'><p>The translation data or <code>nil</code> if the translation failed.</p>
|
|
367
|
+
</div>
|
|
368
|
+
|
|
369
|
+
</li>
|
|
370
|
+
|
|
371
|
+
</ul>
|
|
372
|
+
|
|
373
|
+
</div><table class="source_code">
|
|
374
|
+
<tr>
|
|
375
|
+
<td>
|
|
376
|
+
<pre class="lines">
|
|
377
|
+
|
|
378
|
+
|
|
379
|
+
37
|
|
380
|
+
38
|
|
381
|
+
39
|
|
382
|
+
40
|
|
383
|
+
41
|
|
384
|
+
42
|
|
385
|
+
43
|
|
386
|
+
44
|
|
387
|
+
45
|
|
388
|
+
46
|
|
389
|
+
47
|
|
390
|
+
48
|
|
391
|
+
49
|
|
392
|
+
50
|
|
393
|
+
51
|
|
394
|
+
52
|
|
395
|
+
53
|
|
396
|
+
54
|
|
397
|
+
55
|
|
398
|
+
56</pre>
|
|
399
|
+
</td>
|
|
400
|
+
<td>
|
|
401
|
+
<pre class="code"><span class="info file"># File 'lib/pincerna/translation.rb', line 37</span>
|
|
402
|
+
|
|
403
|
+
<span class='kw'>def</span> <span class='id identifier rubyid_perform_filtering'>perform_filtering</span><span class='lparen'>(</span><span class='id identifier rubyid_from'>from</span><span class='comma'>,</span> <span class='id identifier rubyid_to'>to</span><span class='comma'>,</span> <span class='id identifier rubyid_value'>value</span><span class='rparen'>)</span>
|
|
404
|
+
<span class='comment'># By default we translate from English
|
|
405
|
+
</span> <span class='kw'>if</span> <span class='op'>!</span><span class='id identifier rubyid_to'>to</span> <span class='kw'>then</span>
|
|
406
|
+
<span class='id identifier rubyid_to'>to</span> <span class='op'>=</span> <span class='id identifier rubyid_from'>from</span>
|
|
407
|
+
<span class='id identifier rubyid_from'>from</span> <span class='op'>=</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>en</span><span class='tstring_end'>"</span></span>
|
|
408
|
+
<span class='kw'>end</span>
|
|
409
|
+
|
|
410
|
+
<span class='id identifier rubyid_response'>response</span> <span class='op'>=</span> <span class='const'>Pincerna</span><span class='op'>::</span><span class='const'>Cache</span><span class='period'>.</span><span class='id identifier rubyid_instance'>instance</span><span class='period'>.</span><span class='id identifier rubyid_use'>use</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>translation:</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_from'>from</span><span class='embexpr_end'>}</span><span class='tstring_content'>:</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_to'>to</span><span class='embexpr_end'>}</span><span class='tstring_content'>:</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_value'>value</span><span class='embexpr_end'>}</span><span class='tstring_end'>"</span></span><span class='comma'>,</span> <span class='const'>Pincerna</span><span class='op'>::</span><span class='const'>Cache</span><span class='op'>::</span><span class='const'>EXPIRATIONS</span><span class='lbracket'>[</span><span class='symbol'>:short</span><span class='rbracket'>]</span><span class='rparen'>)</span> <span class='lbrace'>{</span>
|
|
411
|
+
<span class='id identifier rubyid_fetch_remote_resource'>fetch_remote_resource</span><span class='lparen'>(</span><span class='const'>URL</span><span class='comma'>,</span> <span class='lbrace'>{</span><span class='label'>client:</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>p</span><span class='tstring_end'>"</span></span><span class='comma'>,</span> <span class='label'>text:</span> <span class='id identifier rubyid_value'>value</span><span class='comma'>,</span> <span class='label'>sl:</span> <span class='id identifier rubyid_from'>from</span><span class='comma'>,</span> <span class='label'>tl:</span> <span class='id identifier rubyid_to'>to</span><span class='comma'>,</span> <span class='label'>multires:</span> <span class='int'>1</span><span class='comma'>,</span> <span class='label'>ssel:</span> <span class='int'>0</span><span class='comma'>,</span> <span class='label'>tsel:</span> <span class='int'>0</span><span class='comma'>,</span> <span class='label'>sc:</span> <span class='int'>1</span><span class='comma'>,</span> <span class='label'>ie:</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>UTF-8</span><span class='tstring_end'>"</span></span><span class='comma'>,</span> <span class='label'>oe:</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>UTF-8</span><span class='tstring_end'>"</span></span><span class='rbrace'>}</span><span class='rparen'>)</span>
|
|
412
|
+
<span class='rbrace'>}</span>
|
|
413
|
+
|
|
414
|
+
<span class='comment'># Parse results
|
|
415
|
+
</span> <span class='kw'>if</span> <span class='id identifier rubyid_response'>response</span><span class='lbracket'>[</span><span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>dict</span><span class='tstring_end'>"</span></span><span class='rbracket'>]</span> <span class='kw'>then</span>
|
|
416
|
+
<span class='id identifier rubyid_translations'>translations</span> <span class='op'>=</span> <span class='id identifier rubyid_response'>response</span><span class='lbracket'>[</span><span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>dict</span><span class='tstring_end'>"</span></span><span class='rbracket'>]</span><span class='lbracket'>[</span><span class='int'>0</span><span class='rbracket'>]</span><span class='lbracket'>[</span><span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>entry</span><span class='tstring_end'>"</span></span><span class='rbracket'>]</span><span class='period'>.</span><span class='id identifier rubyid_map'>map</span> <span class='lbrace'>{</span><span class='op'>|</span><span class='id identifier rubyid_t'>t</span><span class='op'>|</span> <span class='id identifier rubyid_t'>t</span><span class='lbracket'>[</span><span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>word</span><span class='tstring_end'>"</span></span><span class='rbracket'>]</span> <span class='rbrace'>}</span>
|
|
417
|
+
<span class='lbrace'>{</span><span class='label'>main:</span> <span class='id identifier rubyid_translations'>translations</span><span class='period'>.</span><span class='id identifier rubyid_shift'>shift</span><span class='comma'>,</span> <span class='label'>alternatives:</span> <span class='id identifier rubyid_translations'>translations</span><span class='rbrace'>}</span>
|
|
418
|
+
<span class='kw'>else</span>
|
|
419
|
+
<span class='id identifier rubyid_translation'>translation</span> <span class='op'>=</span> <span class='id identifier rubyid_response'>response</span><span class='lbracket'>[</span><span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>sentences</span><span class='tstring_end'>"</span></span><span class='rbracket'>]</span><span class='lbracket'>[</span><span class='int'>0</span><span class='rbracket'>]</span><span class='lbracket'>[</span><span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>trans</span><span class='tstring_end'>"</span></span><span class='rbracket'>]</span>
|
|
420
|
+
<span class='lbrace'>{</span><span class='label'>main:</span> <span class='id identifier rubyid_translation'>translation</span><span class='rbrace'>}</span> <span class='kw'>if</span> <span class='id identifier rubyid_translation'>translation</span> <span class='op'>!=</span> <span class='id identifier rubyid_value'>value</span>
|
|
421
|
+
<span class='kw'>end</span>
|
|
422
|
+
<span class='kw'>end</span></pre>
|
|
423
|
+
</td>
|
|
424
|
+
</tr>
|
|
425
|
+
</table>
|
|
426
|
+
</div>
|
|
427
|
+
|
|
428
|
+
<div class="method_details ">
|
|
429
|
+
<h3 class="signature " id="process_results-instance_method">
|
|
430
|
+
|
|
431
|
+
- (<tt>Array</tt>) <strong>process_results</strong>(results)
|
|
432
|
+
|
|
433
|
+
|
|
434
|
+
|
|
435
|
+
|
|
436
|
+
|
|
437
|
+
</h3><div class="docstring">
|
|
438
|
+
<div class="discussion">
|
|
439
|
+
<p>Processes items to obtain feedback items.</p>
|
|
440
|
+
|
|
441
|
+
|
|
442
|
+
</div>
|
|
443
|
+
</div>
|
|
444
|
+
<div class="tags">
|
|
445
|
+
<p class="tag_title">Parameters:</p>
|
|
446
|
+
<ul class="param">
|
|
447
|
+
|
|
448
|
+
<li>
|
|
449
|
+
|
|
450
|
+
<span class='name'>results</span>
|
|
451
|
+
|
|
452
|
+
|
|
453
|
+
<span class='type'>(<tt>Array</tt>)</span>
|
|
454
|
+
|
|
455
|
+
|
|
456
|
+
|
|
457
|
+
—
|
|
458
|
+
<div class='inline'><p>The items to process.</p>
|
|
459
|
+
</div>
|
|
460
|
+
|
|
461
|
+
</li>
|
|
462
|
+
|
|
463
|
+
</ul>
|
|
464
|
+
|
|
465
|
+
<p class="tag_title">Returns:</p>
|
|
466
|
+
<ul class="return">
|
|
467
|
+
|
|
468
|
+
<li>
|
|
469
|
+
|
|
470
|
+
|
|
471
|
+
<span class='type'>(<tt>Array</tt>)</span>
|
|
472
|
+
|
|
473
|
+
|
|
474
|
+
|
|
475
|
+
—
|
|
476
|
+
<div class='inline'><p>The feedback items.</p>
|
|
477
|
+
</div>
|
|
478
|
+
|
|
479
|
+
</li>
|
|
480
|
+
|
|
481
|
+
</ul>
|
|
482
|
+
|
|
483
|
+
</div><table class="source_code">
|
|
484
|
+
<tr>
|
|
485
|
+
<td>
|
|
486
|
+
<pre class="lines">
|
|
487
|
+
|
|
488
|
+
|
|
489
|
+
62
|
|
490
|
+
63
|
|
491
|
+
64
|
|
492
|
+
65</pre>
|
|
493
|
+
</td>
|
|
494
|
+
<td>
|
|
495
|
+
<pre class="code"><span class="info file"># File 'lib/pincerna/translation.rb', line 62</span>
|
|
496
|
+
|
|
497
|
+
<span class='kw'>def</span> <span class='id identifier rubyid_process_results'>process_results</span><span class='lparen'>(</span><span class='id identifier rubyid_results'>results</span><span class='rparen'>)</span>
|
|
498
|
+
<span class='id identifier rubyid_alternatives'>alternatives</span> <span class='op'>=</span> <span class='id identifier rubyid_results'>results</span><span class='lbracket'>[</span><span class='symbol'>:alternatives</span><span class='rbracket'>]</span> <span class='op'>?</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>Alternatives: </span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_results'>results</span><span class='lbracket'>[</span><span class='symbol'>:alternatives</span><span class='rbracket'>]</span><span class='period'>.</span><span class='id identifier rubyid_join'>join</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>, </span><span class='tstring_end'>"</span></span><span class='rparen'>)</span><span class='embexpr_end'>}</span><span class='tstring_end'>"</span></span> <span class='op'>:</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>Action this item to copy the translation on the clipboard.</span><span class='tstring_end'>"</span></span>
|
|
499
|
+
<span class='lbracket'>[</span><span class='lbrace'>{</span><span class='label'>title:</span> <span class='id identifier rubyid_results'>results</span><span class='lbracket'>[</span><span class='symbol'>:main</span><span class='rbracket'>]</span><span class='comma'>,</span> <span class='label'>arg:</span> <span class='id identifier rubyid_results'>results</span><span class='lbracket'>[</span><span class='symbol'>:main</span><span class='rbracket'>]</span><span class='comma'>,</span> <span class='label'>subtitle:</span> <span class='id identifier rubyid_alternatives'>alternatives</span><span class='comma'>,</span> <span class='label'>icon:</span> <span class='const'>ICON</span><span class='rbrace'>}</span><span class='rbracket'>]</span>
|
|
500
|
+
<span class='kw'>end</span></pre>
|
|
501
|
+
</td>
|
|
502
|
+
</tr>
|
|
503
|
+
</table>
|
|
504
|
+
</div>
|
|
505
|
+
|
|
506
|
+
</div>
|
|
507
|
+
|
|
508
|
+
</div>
|
|
509
|
+
|
|
510
|
+
<div id="footer">
|
|
511
|
+
Generated on Thu Aug 18 15:50:05 2016 by
|
|
512
|
+
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
|
513
|
+
0.8.7 (ruby-2.3.0).
|
|
514
|
+
</div>
|
|
515
|
+
|
|
516
|
+
</body>
|
|
517
|
+
</html>
|